org.apache.commons.collections15.Transformer类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.apache.commons.collections15.Transformer类的一些代码示例,展示了Transformer类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transformer类的具体详情如下:
包路径:org.apache.commons.collections15.Transformer
类名称: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: org.opendaylight.controller.thirdparty/net.sf.jung2

/**
 * Returns the prior probability for <code>v</code>.
 * @param v the vertex whose prior probability is being queried
 * @return the prior probability for <code>v</code>
 */
protected S getVertexPrior(V v)
{
  return vertex_priors.transform(v);
}

代码示例来源:origin: geogebra/geogebra

/**
 * Returns the prior probability for <code>v</code>.
 * 
 * @param v
 *            the vertex whose prior probability is being queried
 * @return the prior probability for <code>v</code>
 */
protected S getVertexPrior(V v) {
  return vertex_priors.transform(v);
}

代码示例来源:origin: girtel/Net2Plan

@Override
  public boolean evaluate(E edge)
  {
    if (nev != null && nev.transform(edge) == Double.MAX_VALUE)
      return false;
    else if (edgeSpareCapacityTransformer != null && edgeSpareCapacityTransformer.transform(edge) < requiredCapacity) return false;
    return true;
  }
});

代码示例来源:origin: geogebra/geogebra

/**
 * Transforms the input to result via each decorated transformer
 *
 * @param object
 *            the input object passed to the first transformer
 * @return the transformed result
 */
@Override
public O transform(I object) {
  Object intermediate = object;
  for (int i = 0; i < iTransformers.length; i++) {
    intermediate = iTransformers[i].transform(intermediate);
  }
  return (O) intermediate;
}

代码示例来源:origin: org.opendaylight.nic/of-renderer

private double calculatePathCost(final List<E> path){
    double result = 0;
    for(E edge : path) {
      result += defaultEdgeWeight.transform(edge).doubleValue();
    }
    return result;
  }
}

代码示例来源:origin: SmartDataAnalytics/Sparqlify

@Override
public V get(Object key) {
  V result;
  try {
    @SuppressWarnings("unchecked")
    K k = (K)key;
    
    K normKey = keyNormalizer.transform(k);
    
    result = map.get(normKey);
    
  } catch(ClassCastException e) {
    result = null;
  }            
  
  return result;
}

代码示例来源:origin: SmartDataAnalytics/Sparqlify

@Override
public boolean containsKey(Object key) {
  boolean result;
  try {
    @SuppressWarnings("unchecked")
    K k = (K)key;
    
    K normKey = keyNormalizer.transform(k);
      
    result = map.containsKey(normKey);
  } catch(ClassCastException e) {
    result = false;
  }            
  
  return result;
}

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

@Override
  public Integer transform(ONDEXConcept arg0) {
    if (entitiesSizes.containsKey(arg0))
      return entitiesSizes.get(arg0);
    return oldSizes.transform(arg0);
  }
};

代码示例来源:origin: net.sourceforge.ondex.modules/tab-tools

@Override
public List<AttributeExtractor> transform(Integer arg0) {
  List<AttributeExtractor> existing = null;
  for (Transformer<Integer, List<AttributeExtractor>> transformer : transformers) {
    List<AttributeExtractor> result = transformer.transform(arg0);
    if (result == null) continue;
    if (existing == null) {
      existing = result;
    } else {
      existing.addAll(result);
    }
  }
  return existing;
}

代码示例来源:origin: org.apache.batchee/batchee-maven-plugin

private Rectangle getBound(final Node n, final Transformer<Node, Shape> vst) {
  if (vst == null) {
    return new Rectangle(0, 0);
  }
  return vst.transform(n).getBounds();
}

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

@Override
  public Integer transform(ONDEXRelation arg0) {
    if (entitiesSizes.containsKey(arg0))
      return entitiesSizes.get(arg0);
    if (oldSizes != null)
      return oldSizes.transform(arg0);
    return Config.defaultEdgeSize;
  }
};

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2-experimental

@Override
  public Integer transform(ONDEXRelation e) {
    if (!cache.containsKey(e))
      return UNITLENGTHFUNCTION.transform(e);
    return cache.get(e);
  }
}

代码示例来源:origin: geogebra/geogebra

@Override
@SuppressWarnings("unchecked")
public V get(Object key) {
  // create value for key if key is not currently in the map
  if (map.containsKey(key) == false) {
    V value = this.transformer.transform((K) key);
    map.put((K) key, value);
    return value;
  }
  return map.get(key);
}

代码示例来源:origin: girtel/Net2Plan

@Override
  public Point2D transform(V input)
  {
    Point2D p = new Point2D.Double();
    p.setLocation(vertexPositionTransformer.transform(input));
    p.setLocation(p.getX(), -p.getY());
    return p;
  }
};

代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2

/**
 * @see Transformer#transform(Object)
 */
public Number transform(VEPair<V,E> arg0)
{
  return delegate.transform(arg0.getE());
}

代码示例来源:origin: iTransformers/netTransformer

public String transform(String s) {
    final Transformer<String, String> transformer = createTransformer();
    if (transformer == null) return null;
    return transformer.transform(s);
  }
};

代码示例来源:origin: iTransformers/netTransformer

public String transform(String s)  {
    final Transformer<String, String> transformer = createTransformer();
    if (transformer == null) return "";
    return transformer.transform(s);
  }
};

代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2

/**
 * Gets the edge weight for <code>e</code> in the context of its (incident) vertex <code>v</code>.
 * @param v the vertex incident to e as a context in which the edge weight is to be calculated
 * @param e the edge whose weight is to be returned
 * @return the edge weight for <code>e</code> in the context of its (incident) vertex <code>v</code>
 */
protected Number getEdgeWeight(V v, E e)
{
  return edge_weights.transform(new VEPair<V,E>(v,e));
}

代码示例来源:origin: iTransformers/netTransformer

private <G> Map<String, String> getParams(String v, Map<String, GraphMLMetadata<String>> vertexMetadata) {
  HashMap<String, String> params = new HashMap<String, String>();
  for (String key : vertexMetadata.keySet()){
    String value = vertexMetadata.get(key).transformer.transform(v);
    if (value == null) continue;
    if (!params.containsKey(key)){
      params.put(key,value);
    } else{
      value = value.concat(", ").concat(params.get(key));
      params.put(key,value);
    }
  }
  return params;
}

代码示例来源:origin: SmartDataAnalytics/Sparqlify

@Override
public V put(K key, V value) {
  K normKey = keyNormalizer.transform(key);

  //if(origToNorm.inverseBidiMap().get(normKey)
  
  
  origToNorm.put(key, normKey);
  map.put(normKey, value);
  
  return value;
}

相关文章

Transformer类方法