K - the generic type of the keyT - the generic type of the valuepublic abstract static class Osgl.IndexedVisitor<K,T> extends Osgl.F2<K,T,Void>
An IndexedVisitor provide a tool to iterate through a Map or indexed list
by passing the key/index and the value to the function.
Use IndexedVisitor to iterate through a List
C.List<Student> students = ...
students.each(new IndexedVisitor() {
@Override
public void visit(int id, Student student) {
System.out.printf("ID: %s, Name: %s", id, student.getName());
}
})
Use IndexedVisitor to iterate through a Map
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
aBool |
protected byte |
aByte |
protected char |
aChar |
protected double |
aDouble |
protected float |
aFloat |
protected long |
aLong |
protected int |
anInt |
protected T |
any |
protected String |
aStr |
protected Map<String,?> |
attr |
| Constructor and Description |
|---|
IndexedVisitor() |
IndexedVisitor(boolean b) |
IndexedVisitor(byte b) |
IndexedVisitor(char c) |
IndexedVisitor(double d) |
IndexedVisitor(float f) |
IndexedVisitor(int i) |
IndexedVisitor(long l) |
IndexedVisitor(Map<String,?> map) |
IndexedVisitor(String s) |
IndexedVisitor(T t) |
| Modifier and Type | Method and Description |
|---|---|
Void |
apply(K id,
T t)
Apply the two params to the function
|
T |
get() |
<T> T |
get(String key) |
boolean |
getBoolean() |
byte |
getByte() |
char |
getChar() |
double |
getDouble() |
float |
getFloat() |
int |
getInt() |
long |
getLong() |
String |
getStr() |
abstract void |
visit(K id,
T t) |
andThen, andThen, applyOrElse, curry, curry, lift, orElsebreakOutprotected T any
protected String aStr
protected boolean aBool
protected int anInt
protected float aFloat
protected double aDouble
protected byte aByte
protected char aChar
protected long aLong
public IndexedVisitor()
public IndexedVisitor(T t)
public IndexedVisitor(String s)
public IndexedVisitor(boolean b)
public IndexedVisitor(int i)
public IndexedVisitor(long l)
public IndexedVisitor(double d)
public IndexedVisitor(float f)
public IndexedVisitor(byte b)
public IndexedVisitor(char c)
public T get()
public String getStr()
public boolean getBoolean()
public int getInt()
public long getLong()
public float getFloat()
public double getDouble()
public char getChar()
public byte getByte()
public <T> T get(String key)
public final Void apply(K id, T t)
Osgl.Func2In case implementing a partial function, it can throw out an
NotAppliedException if the function is not defined for
the given parameter(s)
id - the first argument of type P1t - the second argument of type P2Copyright © 2017. All Rights Reserved.