Java Code Examples for org.osgl.Lang#Function

The following examples show how to use org.osgl.Lang#Function . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListBase.java    From java-tool with Apache License 2.0 6 votes vote down vote up
@Override
public Lang.T2<C.List<T>, C.List<T>> split(final Lang.Function<? super T, Boolean> predicate) {
    final C.List<T> left = C.newList();
    final C.List<T> right = C.newList();
    accept(new $.Visitor<T>() {
        @Override
        public void visit(T t) throws Lang.Break {
            if (predicate.apply(t)) {
                left.add(t);
            } else {
                right.add(t);
            }
        }
    });
    if (isImmutable() || isReadOnly()) {
        return $.T2(C.list(left), C.list(right));
    }
    return $.T2(left, right);
}
 
Example 2
Source File: AdaptiveMapPropertyGetter.java    From java-tool with Apache License 2.0 5 votes vote down vote up
public AdaptiveMapPropertyGetter(Lang.Function<Class<?>, Object> objectFactory,
                                 Lang.Func2<String, Class<?>, ?> stringValueResolver,
                                 NullValuePolicy nullValuePolicy,
                                 Class<?> keyType,
                                 Class<?> valType) {
    super(objectFactory, stringValueResolver, nullValuePolicy, keyType, valType);
}
 
Example 3
Source File: ReflectionPropertyHandler.java    From java-tool with Apache License 2.0 5 votes vote down vote up
ReflectionPropertyHandler(Lang.Function<Class<?>, Object> objectFactory,
                          Lang.Func2<String, Class<?>, ?> stringValueResolver,
                          PropertyGetter.NullValuePolicy nullValuePolicy,
                          Class entityClass, Method m, Field f) {
    super(objectFactory, stringValueResolver, nullValuePolicy);
    init(entityClass, m, f);
}
 
Example 4
Source File: PropertyHandlerBase.java    From java-tool with Apache License 2.0 5 votes vote down vote up
PropertyHandlerBase(Lang.Function<Class<?>, Object> objectFactory,
                    Lang.Func2<String, Class<?>, ?> stringValueResolver,
                    PropertyGetter.NullValuePolicy nullValuePolicy) {
    setObjectFactory(objectFactory);
    setStringValueResolver(stringValueResolver);
    if (null == nullValuePolicy) {
        nullValuePolicy = PropertyGetter.NullValuePolicy.RETURN_NULL;
    }
    setNullValuePolicy(nullValuePolicy);
}
 
Example 5
Source File: MapPropertyGetter.java    From java-tool with Apache License 2.0 5 votes vote down vote up
public MapPropertyGetter(Lang.Function<Class<?>, Object> objectFactory,
                         Lang.Func2<String, Class<?>, ?> stringValueResolver,
                         PropertyGetter.NullValuePolicy nullValuePolicy,
                         Class<?> keyType,
                         Class<?> valType) {
    super(objectFactory, stringValueResolver, nullValuePolicy, keyType, valType);
}
 
Example 6
Source File: ReflectionPropertyGetter.java    From java-tool with Apache License 2.0 5 votes vote down vote up
public ReflectionPropertyGetter(Lang.Function<Class<?>, Object> objectFactory,
                                Lang.Func2<String, Class<?>, ?> stringValueResolver,
                                NullValuePolicy nullValuePolicy,
                                Class entityClass, Method m, Field f,
                                ReflectionPropertyHandlerFactory factory) {
    super(objectFactory, stringValueResolver, nullValuePolicy, entityClass, m, f);
    this.factory = $.requireNotNull(factory);
}
 
Example 7
Source File: MapPropertyHandler.java    From java-tool with Apache License 2.0 5 votes vote down vote up
public MapPropertyHandler(Lang.Function<Class<?>, Object> objectFactory,
                          Lang.Func2<String, Class<?>, ?> stringValueResolver,
                          Class<?> keyType,
                          Class<?> valType) {
    super(objectFactory, stringValueResolver);
    this.keyType = $.requireNotNull(keyType);
    this.valType = $.requireNotNull(valType);
}
 
Example 8
Source File: MapPropertySetter.java    From java-tool with Apache License 2.0 5 votes vote down vote up
MapPropertySetter(Lang.Function<Class<?>, Object> objectFactory,
                  Lang.Func2<String, Class<?>, ?> stringValueResolver,
                  Class<?> keyType,
                  Class<?> valType) {
    super(objectFactory, stringValueResolver, keyType, valType);
    setNullValuePolicy(PropertyGetter.NullValuePolicy.CREATE_NEW);
}
 
Example 9
Source File: ListPropertyHandler.java    From java-tool with Apache License 2.0 5 votes vote down vote up
ListPropertyHandler(Lang.Function<Class<?>, Object> objectFactory,
                    Lang.Func2<String, Class<?>, ?> stringValueResolver,
                    PropertyGetter.NullValuePolicy nullValuePolicy,
                    Class<?> itemType) {
    super(objectFactory, stringValueResolver, nullValuePolicy);
    this.itemType = $.requireNotNull(itemType);
}
 
Example 10
Source File: ListBase.java    From java-tool with Apache License 2.0 5 votes vote down vote up
@Override
public <K, V> C.Map<K, V> toMap(Lang.Function<? super T, ? extends K> keyExtractor, Lang.Function<? super T, ? extends V> valExtractor) {
    C.Map<K, V> map = C.newMap();
    for (T v : this) {
        map.put(keyExtractor.apply(v), valExtractor.apply(v));
    }
    return map;
}
 
Example 11
Source File: ListBase.java    From java-tool with Apache License 2.0 5 votes vote down vote up
@Override
public <K> C.Map<K, T> toMapByVal(Lang.Function<? super T, ? extends K> keyExtractor) {
    C.Map<K, T> map = C.newMap();
    for (T v : this) {
        map.put(keyExtractor.apply(v), v);
    }
    return map;
}
 
Example 12
Source File: AdaptiveMapPropertySetter.java    From java-tool with Apache License 2.0 5 votes vote down vote up
AdaptiveMapPropertySetter(Lang.Function<Class<?>, Object> objectFactory,
                          Lang.Func2<String, Class<?>, ?> stringValueResolver,
                          Class<?> keyType,
                          Class<?> valType) {
    super(objectFactory, stringValueResolver, keyType, valType);
    setNullValuePolicy(PropertyGetter.NullValuePolicy.CREATE_NEW);
}
 
Example 13
Source File: AdaptiveMapPropertyGetter.java    From java-tool with Apache License 2.0 4 votes vote down vote up
public AdaptiveMapPropertyGetter(Lang.Function<Class<?>, Object> objectFactory,
                                 Lang.Func2<String, Class<?>, ?> stringValueResolver,
                                 Class<?> keyType,
                                 Class<?> valType) {
    super(objectFactory, stringValueResolver, keyType, valType);
}
 
Example 14
Source File: AdaptiveBean.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public Set<Map.Entry<String, Object>> entrySet(Lang.Function<BeanInfo, Boolean> fieldFilter) {
    return Util.entrySet(this, fieldFilter);
}
 
Example 15
Source File: ListPropertySetter.java    From java-tool with Apache License 2.0 4 votes vote down vote up
public ListPropertySetter(Lang.Function<Class<?>, Object> objectFactory,
                   Lang.Func2<String, Class<?>, ?> stringValueResolver,
                   Class<?> itemType) {
    super(objectFactory, stringValueResolver, itemType);
    setNullValuePolicy(PropertyGetter.NullValuePolicy.CREATE_NEW);
}
 
Example 16
Source File: ListPropertyHandler.java    From java-tool with Apache License 2.0 4 votes vote down vote up
ListPropertyHandler(Lang.Function<Class<?>, Object> objectFactory,
                    Lang.Func2<String, Class<?>, ?> stringValueResolver,
                    Class<?> itemType) {
    super(objectFactory, stringValueResolver);
    this.itemType = $.requireNotNull(itemType);
}
 
Example 17
Source File: ListPropertyGetter.java    From java-tool with Apache License 2.0 4 votes vote down vote up
public ListPropertyGetter(Lang.Function<Class<?>, Object> objectFactory,
                          Lang.Func2<String, Class<?>, ?> stringValueResolver,
                          PropertyGetter.NullValuePolicy nullValuePolicy,
                          Class<?> itemType) {
    super(objectFactory, stringValueResolver, nullValuePolicy, itemType);
}
 
Example 18
Source File: ListPropertyGetter.java    From java-tool with Apache License 2.0 4 votes vote down vote up
public ListPropertyGetter(Lang.Function<Class<?>, Object> objectFactory,
                          Lang.Func2<String, Class<?>, ?> stringValueResolver,
                          Class<?> itemType) {
    super(objectFactory, stringValueResolver, itemType);
}
 
Example 19
Source File: PropertyHandlerBase.java    From java-tool with Apache License 2.0 4 votes vote down vote up
@Override
public void setObjectFactory(Lang.Function<Class<?>, Object> factory) {
    this.objectFactory = $.requireNotNull(factory);
}
 
Example 20
Source File: SimpleAdaptiveMap.java    From java-tool with Apache License 2.0 4 votes vote down vote up
@Override
public Set<Map.Entry<String, Object>> entrySet(Lang.Function<BeanInfo, Boolean> fieldFilter) {
    throw E.unsupport();
}