public static <T extends Named> Map<String, T> toMap(T[] a) { Map map = new LinkedHashMap(); if(null != a) { for(T item : a) { map.put(item.getName(), item); } } return map; }
/** * Sets the value of field. */ default <T extends EntityBase> T set(Named field,Object value) { return set(field.getName(), value); }
public final <T extends Model> T set(Named field,Object value){ set(field.getName(), value); return (T)this; }
public boolean test(T object) { return Strings.equalsIgnoreCase(object.getName(),name); } };
public final Object get(Named field) { return get(field.getName()); }
/** * Returns the named value (may be null). * * <p/> * Returns <code>null</code> if the name not exists. */ default <T> T get(Named named) { return get(named.getName()); }
public boolean test(T object) { return Strings.equals(object.getName(), name); } };
/** * Finds all the tables matches the given table names. */ public DbTable[] findTables(Named...names){ List<DbTable> tables = new ArrayList<>(); for(Named name : names){ DbTable table = findTable(name.getName()); if(null != table){ tables.add(table); } } return tables.toArray(new DbTable[tables.size()]); }
/** * Returns the named value (may be null). * * <p/> * Returns <code>null</code> if the name not exists. */ default <T> T get(Named named, Class<T> type) { Object v = get(named.getName()); return Objects2.isEmpty(v) ? null : Converts.convert(v, type); }
private static String getLocalizedKeyPrefix(BeanType bt, Named bean) { LocalizeKey a = bt.getBeanClass().getAnnotation(LocalizeKey.class); String keyPrefix = null != a ? a.value() : null; if(Strings.isEmpty(keyPrefix) && bean instanceof LocalizeKeyed){ keyPrefix = ((LocalizeKeyed)bean).getLocalizeKey(); } if(Strings.isEmpty(keyPrefix)){ keyPrefix = bt.getBeanClass().getName(); } return keyPrefix + "." + bean.getName().toLowerCase(); }