leap.lang.New类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(218)

本文整理了Java中leap.lang.New类的一些代码示例,展示了New类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。New类的具体详情如下:
包路径:leap.lang.New
类名称:New

New介绍

暂无

代码示例

代码示例来源:origin: org.leapframework/leap-core

protected static Map<String,Object> newExprVars(AppConfig config) {
  Map<String, Object> vars = New.hashMap();
  vars.put("config", config);
  vars.put("properties",  config.getProperties());
  return vars;
}

代码示例来源:origin: org.leapframework/leap-lang

/**
 * Converts an iterable into a list. If the iterable is already a list, it is returned. 
 * Otherwise, an {@link java.util.ArrayList} is created with the contents of the iterable in the same iteration order.
 */	
public static <T> List<T> toList(Iterable<T> iterable){
  return iterable instanceof List ? (List<T>)iterable : New.arrayList(iterable);
}

代码示例来源:origin: org.leapframework/leap-lang

public static <T> Map<String, T> toMap(Collection<T> c, Function<T, String> key) {
  if(null == c) {
    return New.linkedHashMap();
  }
  Map<String,T> map = new LinkedHashMap<>(c.size());
  for(T item : c) {
    map.put(key.apply(item), item);
  }
  return map;
}

代码示例来源:origin: org.leapframework/leap-webapi

public MApiPermission[] resolvePermissions(Route route, Class<?> resourceType) {
  List<MApiPermission> list = New.arrayList();
  String resourceName = resourceType.getSimpleName();
  Map<String,Object> vars = New.hashMap("resource", resourceName);
  permissions.forEach(p -> {
    if(p.matches(route)) {
      String value = eval(p.getValue(), vars);
      String desc  = eval(p.getDescription(), vars);
      list.add(new MApiPermission(value, desc));
    }
  });
  if(list.isEmpty() && null != defaultPermission) {
    list.add(new MApiPermission(defaultPermission.getValue(), defaultPermission.getDescription()));
  }
  return list.toArray(new MApiPermission[0]);
}

代码示例来源:origin: org.leapframework/leap-lang

if(propertyVal == null){
  if(type.isAssignableFrom(List.class)){
    ArrayList arr = New.arrayList();
    tryIncreaseSize(arr,index);
    arr.set(index, Converts.convert(value, bp.getElementType()));
      bp.setValue(bean, arr);
    }else{
      Object[] arr =  New.array(type.getComponentType(), index+1);
      arr[index] = Converts.convert(value, type.getComponentType());
      bp.setValue(bean, arr);
      int len = Array.getLength(arr);
      if(len <= index){
        List<Object> newArr = New.arrayList();
        for(int i=0;i<len;i++){
          newArr.add(Array.get(arr,i));
      Object[] arr = (Object[])propertyVal;
      if(arr.length <= index){
        List<Object> newArr = New.arrayList();
        for(Object obj : arr){
          newArr.add(obj);

代码示例来源:origin: org.leapframework/leap-lang

/**
 * Converts a T[] array to a {@link Set}<T>.
 */
@SuppressWarnings("unchecked")
public static <E,T extends E> Set<E> toSet(T... elements){
  return New.<E>linkedHashSet(elements);
}

代码示例来源:origin: org.leapframework/leap-lang

/**
 * Copies an iterable's elements into an array.
 * 
 * @param iterable the iterable to copy
 * @param type the type of the elements
 * @return a newly-allocated array into which all the elements of the iterable have been copied
 */
public static <T> T[] toArray(Iterable<? extends T> iterable, Class<T> type) {
  Collection<? extends T> collection = toCollection(iterable);
  T[] array = New.array(type, collection.size());
  return collection.toArray(array);
}

代码示例来源:origin: org.leapframework/leap-lang

@Override
  public Set<E> toSet() {
    return New.linkedHashSet(this);
  }
}

代码示例来源:origin: org.leapframework/leap-lang

@Override
public List<E> toList() {
  return New.arrayList(this);
}

代码示例来源:origin: org.leapframework/leap-oauth2

@Override
public String generateIdToken(AuthzAuthentication authc) {
  return generateIdToken(authc,New.hashMap());
}

代码示例来源:origin: org.leapframework/leap-lang

public static <K,V> Map<K,V> buildMap(Map<K,? extends Buildable<V>> builders) {
  Map<K,V> m = New.linkedHashMap();
  for(Entry<K, ? extends Buildable<V>> e : builders.entrySet()) {
    m.put(e.getKey(), e.getValue().build());
  }
  return m;
}

代码示例来源:origin: org.leapframework/leap-orm

@Override
  public void process(int rownum, String[] values) throws Exception {
    //skip header
    if(rownum == 1){
      return;
    }
    
    //columns : singular,acronyms
    String singular = values[0].toLowerCase();
    String acronyms = values[1].toLowerCase();
    Set<String> acronymSet = New.linkedHashSet(Strings.split(acronyms,'|'));
    
    singuralToAcronyms.put(singular, acronymSet);
    allAcronyms.addAll(acronymSet);
  }
});

代码示例来源:origin: org.leapframework/leap-db

public GenericSqlCommand(GenericDb db,String... sqls) {
  super(db);
  this.sqls = New.arrayList(sqls);
}

代码示例来源:origin: org.leapframework/leap-oauth2-webapp

@Override
public UserPrincipal lookupUserInfo(String at, String userId) {
  return requestUserInfo(New.hashMap("access_token", at));
}

代码示例来源:origin: org.leapframework/leap-orm

private Map<String, FieldMapping> createFieldNameToFieldsMap() {
  Map<String, FieldMapping> map = New.linkedHashMap();
  for (FieldMapping fm : fieldMappings) {
    map.put(fm.getFieldName().toLowerCase(), fm);
  }
  return Collections.unmodifiableMap(map);
}

代码示例来源:origin: org.leapframework/jmms-engine

public List<Object> arrayToList(Object[] a) {
  return New.arrayList(a);
}

代码示例来源:origin: org.leapframework/leap-oauth2-server

@Override
public String generateIdToken(AuthzAuthentication authc) {
  return generateIdToken(authc,New.hashMap());
}

代码示例来源:origin: org.leapframework/leap-orm

private Map<String, FieldMapping> createColumnNameToFieldsMap() {
  Map<String, FieldMapping> map = New.linkedHashMap();
  for (FieldMapping fm : fieldMappings) {
    map.put(fm.getColumn().getName().toLowerCase(), fm);
  }
  return Collections.unmodifiableMap(map);
}

代码示例来源:origin: org.leapframework/leap-db

protected AlterTable doDropColumn(String columnName){
  if(null == columnsToDrop){
    columnsToDrop = New.arrayList(columnName);
  }else{
    columnsToDrop.add(columnName);
  }
  
  return this;
}

代码示例来源:origin: org.leapframework/leap-lang

public static Map<String, String> queryStringToMap(String queryString){
  Map<String, String> map = New.hashMap();
  if(Strings.isNotEmpty(queryString)){
    String[] kvs = Strings.split(queryString,'&');
    for(String kvStr : kvs){
      int idx = kvStr.indexOf('=');
      if(idx < 0){
        map.put(kvStr.trim(),null);
      }else if(idx >= kvStr.length()){
        String k = kvStr.substring(0,idx);
        map.put(k,null);
      }else {
        String k = kvStr.substring(0,idx);
        String v = kvStr.substring(idx+1);
        map.put(k,v);
      }
    }
  }
  return map;
}

相关文章