Java Code Examples for java.util.function.Function.identity()

The following are Jave code examples for showing how to use identity() of the java.util.function.Function class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Unified-World-Units   File: CompositeUnit.java   View Source Code Vote up 6 votes
/**
 * {@inheritDoc}
 */
@Override
public Function<BigDecimalAmount, BigDecimalAmount> getTranslationFromCanonical() {
	Function<BigDecimalAmount, BigDecimalAmount> result = Function.identity();

	for (UnitCount unitCount : unitCounter.getBaseUnits()) {
		BaseUnit unit = unitCount.getUnit();
		int count = unitCount.getCount();

		if (count > 0) {
			for (int i = 0; i < count; i++) {
				result = result.andThen(unit.getTranslationFromCanonical());
			}
		} else if (count < 0) {
			for (int i = 0; i > count; i--) {
				result = result.andThen(unit.getTranslationToCanonical());
			}
		}
	}

	return result;
}
 
Example 2
Project: TSBW4J   File: Util.java   View Source Code Vote up 5 votes
public static <T extends Unit> Collector<T, Group<T>, Group<T>> toGroup() {
return new Collector<T, Group<T>, Group<T>>(){

	@Override
	public Supplier<Group<T>> supplier() {
		return (Supplier<Group<T>>) Group::new;
	}

	@Override
	public BiConsumer<Group<T>, T> accumulator() {
		return (group, value) -> group.add(value);
	}
	
	@Override
	public BinaryOperator<Group<T>> combiner() {
		return (left, right) -> { left.addAll(right); return left; };
	}

	@Override
	public Function<Group<T>, Group<T>> finisher() {
		return Function.identity();
	}

	@Override
	public Set<Characteristics> characteristics() {
		return Collections.singleton(Characteristics.IDENTITY_FINISH);
	}
};
  }
 
Example 3
Project: mynlp   File: Setting.java   View Source Code Vote up 5 votes
public static Setting<String> stringSetting(String key, String value) {
    Setting<String> setting = new Setting<>();
    setting.key = key;
    setting.defaultValue = value;
    setting.parse = Function.identity();
    return setting;
}
 
Example 4
Project: springmock   File: MockAttachingTestExecutionListener.java   View Source Code Vote up 5 votes
private Optional<Object> tryToGetBean(ApplicationContext applicationContext, DoubleDefinition doubleDefinition) {
	final Function<String, String> beanNameResolver = isFactoryBean(doubleDefinition.getDoubleClass())
			? FactoryBeanRecognizer::getFactoryBeanName
			: Function.identity();

	return Stream
			.concat(
					Stream.of(doubleDefinition.getName()),
					doubleDefinition.getAliases().stream())
			.map(beanNameResolver)
			.map(nameOrAlias -> tryToGetBean(applicationContext, nameOrAlias))
			.filter(Optional::isPresent)
			.findFirst()
			.orElse(Optional.empty());
}
 
Example 5
Project: Unified-World-Units   File: ScalarUnit.java   View Source Code Vote up 5 votes
private ScalarUnit() {
	super(0, "", "", "", Function.identity(), Function.identity());

	this.unitCounter = new UnitCounter();
}
 
Example 6
Project: datarouter   File: CollectorTool.java   View Source Code Vote up 5 votes
private static <T,K,U,M extends Map<K,U>> Collector<T,M,M> relaxedMapCollector(
		Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper,
		Supplier<M> supplier){
	return new Collector<T,M,M>(){

		@Override
		public Supplier<M> supplier(){
			return supplier;
		}

		@Override
		public BiConsumer<M,T> accumulator(){
			return (map, element) -> {
				K key = keyMapper.apply(element);
				U value = valueMapper.apply(element);
				map.put(key, value);
			};
		}

		@Override
		public BinaryOperator<M> combiner(){
			return (map1, map2) -> {
				map1.putAll(map2);
				return map1;
			};
		}

		@Override
		public Function<M,M> finisher(){
			return Function.identity();
		}

		@Override
		public Set<Collector.Characteristics> characteristics(){
			return Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.IDENTITY_FINISH));
		}

	};
}
 
Example 7
Project: strongbox   File: InMemoryPlaintextSecret.java   View Source Code Vote up 4 votes
public InMemoryPlaintextSecret(SecretsGroup secretsGroup, SecretIdentifier secretIdentifier) {
    super(secretsGroup, secretIdentifier, Function.identity());
}
 
Example 8
Project: Unified-World-Units   File: KiloGramUnit.java   View Source Code Vote up 4 votes
private KiloGramUnit() {
	super("Kg", "kilogram", "kilograms",
			Function.identity(),
			Function.identity());
}
 
Example 9
Project: Unified-World-Units   File: AmpereUnit.java   View Source Code Vote up 4 votes
private AmpereUnit() {
	super("A", "ampere", "amperes",
			Function.identity(),
			Function.identity());
}
 
Example 10
Project: Unified-World-Units   File: KelvinUnit.java   View Source Code Vote up 4 votes
private KelvinUnit() {
	super("K", "kelvin", "kelvins",
			Function.identity(),
			Function.identity());
}
 
Example 11
Project: fluentxml4j   File: FromNodeImpl.java   View Source Code Vote up 4 votes
@Override
public SelectMultipleFromNode<Node> selectNodes(String xPathQuery)
{
	XPathExpression xPathExpression = this.context.compile(xPathQuery, this.namespaceContext);
	return new SelectMultipleFromNodeImpl<>(baseNode, xPathExpression, Function.identity());
}
 
Example 12
Project: OOP-ActParser   File: OptionParsers.java   View Source Code Vote up 4 votes
static public Function<String, String> getTextParser() {
    return Function.identity();
}
 
Example 13
Project: https-github.com-RichardWarburton-java-8-Lambdas-exercises   File: AlbumSalesCollector.java   View Source Code Vote up 4 votes
@Override
public Function<AlbumSalesReport, AlbumSalesReport> finisher() {
    return Function.identity();
}
 
Example 14
Project: ProjectAres   File: Collectors.java   View Source Code Vote up 4 votes
@Override
public Function<A, A> finisher() {
    return Function.identity();
}
 
Example 15
Project: ProjectAres   File: Collectors.java   View Source Code Vote up 4 votes
@Override
public Function<ArrayList<T>, ArrayList<T>> finisher() {
    return Function.identity();
}
 
Example 16
Project: ProjectAres   File: ComponentCollector.java   View Source Code Vote up 4 votes
@Override
public Function<Component, Component> finisher() {
    return Function.identity();
}
 
Example 17
Project: kowalski   File: WorkerPoolParser.java   View Source Code Vote up 4 votes
public QueueOutputVisitor() {
	super();
	this.queue = null;
	this.mapper = Function.identity();
}
 
Example 18
Project: qualifier   File: PropertyQualifier.java   View Source Code Vote up 4 votes
@Override public Function<X, X> getGetter() {
    return Function.identity();
}
 
Example 19
Project: Unified-World-Units   File: CandelaUnit.java   View Source Code Vote up 4 votes
private CandelaUnit() {
	super("cd", "candela", "candelas",
			Function.identity(),
			Function.identity());
}
 
Example 20
Project: openjdk-jdk10   File: HttpResponse.java   View Source Code Vote up 2 votes
/**
 * Returns a {@code BodyProcessor} which stores the response body as a
 * byte array.
 * <p>
 * The {@link HttpResponse} using this processor is available after the
 * entire response has been read.
 *
 * @return a body processor
 */
public static BodyProcessor<byte[]> asByteArray() {
    return new ResponseProcessors.ByteArrayProcessor<>(
            Function.identity() // no conversion
    );
}