本文整理了Java中org.apache.commons.collections.Transformer
类的一些代码示例,展示了Transformer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transformer
类的具体详情如下:
包路径:org.apache.commons.collections.Transformer
类名称:Transformer
[英]Defines a functor interface implemented by classes that transform one object into another.
A Transformer
converts the input object to the output object. The input object should be left unchanged. Transformers are typically used for type conversions, or extracting data from an object.
Standard implementations of common transformers are provided by TransformerUtils. These include method invokation, returning a constant, cloning and returning the string value.
[中]定义由将一个对象转换为另一个对象的类实现的函子接口。Transformer
将输入对象转换为输出对象。输入对象应该保持不变。转换器通常用于类型转换,或从对象中提取数据。
TransformerUtils提供了通用变压器的标准实现。其中包括方法调用、返回常量、克隆和返回字符串值。
代码示例来源:origin: commons-collections/commons-collections
/**
* Transforms the input to result via each decorated transformer
*
* @param object the input object passed to the first transformer
* @return the transformed result
*/
public Object transform(Object object) {
for (int i = 0; i < iTransformers.length; i++) {
object = iTransformers[i].transform(object);
}
return object;
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Transforms an object.
* <p>
* The transformer itself may throw an exception if necessary.
*
* @param object the object to transform
* @return a transformed object
*/
protected Object transform(Object object) {
return transformer.transform(object);
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Override to transform the value when using <code>setValue</code>.
*
* @param value the value to transform
* @return the transformed value
* @since Commons Collections 3.1
*/
protected Object checkSetValue(Object value) {
return valueTransformer.transform(value);
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Executes the closure by calling the decorated transformer.
*
* @param input the input object
*/
public void execute(Object input) {
iTransformer.transform(input);
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Transforms a key.
* <p>
* The transformer itself may throw an exception if necessary.
*
* @param object the object to transform
* @throws the transformed object
*/
protected Object transformKey(Object object) {
if (keyTransformer == null) {
return object;
}
return keyTransformer.transform(object);
}
代码示例来源:origin: wildfly/wildfly
/**
* Override to transform the value when using <code>setValue</code>.
*
* @param value the value to transform
* @return the transformed value
* @since Commons Collections 3.1
*/
protected Object checkSetValue(Object value) {
return valueTransformer.transform(value);
}
代码示例来源:origin: wildfly/wildfly
/**
* Transforms the input to result via each decorated transformer
*
* @param object the input object passed to the first transformer
* @return the transformed result
*/
public Object transform(Object object) {
for (int i = 0; i < iTransformers.length; i++) {
object = iTransformers[i].transform(object);
}
return object;
}
代码示例来源:origin: wildfly/wildfly
/**
* Transforms an object.
* <p>
* The transformer itself may throw an exception if necessary.
*
* @param object the object to transform
* @return a transformed object
*/
protected Object transform(Object object) {
return transformer.transform(object);
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Transforms a value.
* <p>
* The transformer itself may throw an exception if necessary.
*
* @param object the object to transform
* @throws the transformed object
*/
protected Object transformValue(Object object) {
if (valueTransformer == null) {
return object;
}
return valueTransformer.transform(object);
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Transforms the given object using the transformer.
* If the transformer is null, the original object is returned as-is.
*
* @param source the object to transform
* @return the transformed object
*/
protected Object transform(Object source) {
if (transformer != null) {
return transformer.transform(source);
}
return source;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Executes the closure by calling the decorated transformer.
*
* @param input the input object
*/
public void execute(Object input) {
iTransformer.transform(input);
}
代码示例来源:origin: wildfly/wildfly
/**
* Transforms the given object using the transformer.
* If the transformer is null, the original object is returned as-is.
*
* @param source the object to transform
* @return the transformed object
*/
protected Object transform(Object source) {
if (transformer != null) {
return transformer.transform(source);
}
return source;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Transforms a key.
* <p>
* The transformer itself may throw an exception if necessary.
*
* @param object the object to transform
* @throws the transformed object
*/
protected Object transformKey(Object object) {
if (keyTransformer == null) {
return object;
}
return keyTransformer.transform(object);
}
代码示例来源:origin: wildfly/wildfly
/**
* Transforms a value.
* <p>
* The transformer itself may throw an exception if necessary.
*
* @param object the object to transform
* @throws the transformed object
*/
protected Object transformValue(Object object) {
if (valueTransformer == null) {
return object;
}
return valueTransformer.transform(object);
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Returns the result of comparing the values from the transform operation.
*
* @param obj1 the first object to transform then compare
* @param obj2 the second object to transform then compare
* @return negative if obj1 is less, positive if greater, zero if equal
*/
public int compare(Object obj1, Object obj2) {
Object value1 = this.transformer.transform(obj1);
Object value2 = this.transformer.transform(obj2);
return this.decorated.compare(value1, value2);
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns the result of comparing the values from the transform operation.
*
* @param obj1 the first object to transform then compare
* @param obj2 the second object to transform then compare
* @return negative if obj1 is less, positive if greater, zero if equal
*/
public int compare(Object obj1, Object obj2) {
Object value1 = this.transformer.transform(obj1);
Object value2 = this.transformer.transform(obj2);
return this.decorated.compare(value1, value2);
}
代码示例来源:origin: commons-collections/commons-collections
public Object get(Object key) {
// create value for key if key is not currently in the map
if (map.containsKey(key) == false) {
if (value instanceof Transformer) {
return ((Transformer) value).transform(key);
}
return value;
}
return map.get(key);
}
代码示例来源:origin: commons-collections/commons-collections
public Object get(Object key) {
// create value for key if key is not currently in the map
if (map.containsKey(key) == false) {
Object value = factory.transform(key);
map.put(key, value);
return value;
}
return map.get(key);
}
代码示例来源:origin: wildfly/wildfly
public Object get(Object key) {
// create value for key if key is not currently in the map
if (map.containsKey(key) == false) {
if (value instanceof Transformer) {
return ((Transformer) value).transform(key);
}
return value;
}
return map.get(key);
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Transforms the input to result by calling the transformer whose matching
* predicate returns true.
*
* @param input the input object to transform
* @return the transformed result
*/
public Object transform(Object input) {
for (int i = 0; i < iPredicates.length; i++) {
if (iPredicates[i].evaluate(input) == true) {
return iTransformers[i].transform(input);
}
}
return iDefault.transform(input);
}
内容来源于网络,如有侵权,请联系作者删除!