congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Beans
Code IndexAdd Tabnine to your IDE (free)

How to use
Beans
in
leap.lang

Best Java code snippets using leap.lang.Beans (Showing top 20 results out of 315)

origin: org.leapframework/leap-db

public void setProperties(PoolProperties props) {
  if(null != props) {
    Beans.copyProperties(props, this);
  }
}

origin: org.leapframework/leap-orm

  @Override
  public Map<String, Object> toMap() {
    Map<String,Object> props = Beans.toMap(raw);
    if(null != map) {
      props.putAll(map);
    }
    return props;
  }
}
origin: org.leapframework/leap-orm

@SuppressWarnings({ "unchecked", "rawtypes" })
public Map<String, Object> toMap(Object object) throws InvalidParametersException {
  if(null == object){
    throw new InvalidParameterException("Cannot convert null to map");
  }
  if(object instanceof Map){
    return ((Map)object);
  }else if(object instanceof Params){
    return ((Params)object).map();
  }
  
  if(Beans.isSimpleProperty(object.getClass())){
    throw new InvalidParameterException("Cannot convert value of simple type '" + object.getClass().getName() + "' to map");
  }
  
  return Beans.toMap(object);
}
origin: org.leapframework/leap-lang

protected static Object getNestedProperty(BeanType beanType,Object bean,BeanProperty bp,String nestedProperty){
  Class<?> nestedBeanClass = bp.getType();
  
  if(Map.class.isAssignableFrom(nestedBeanClass)){
    return getNestedMapProperty(beanType, nestedBeanClass, bp, nestedProperty);
  }
  
  Object nestedBean = bp.getValue(bean);
  
  if(null == nestedBean){
    return null;
  }
  
  return getNestableProperty(BeanType.of(nestedBeanClass), nestedBean, nestedProperty);
}

origin: org.leapframework/leap-core

protected static boolean isBeanParameters(Class<?> cls){
  if(Iterable.class.isAssignableFrom(cls)){
    return false;
  }
  
  if(Map.class.isAssignableFrom(cls)){
    return false;
  }
  
  if(Beans.isSimpleProperty(cls)){
    return false;
  }
  
  if(cls.equals(Object.class)){
    return false;
  }
  
  return true;
}

origin: org.leapframework/leap-lang

  return null;
}else{
  return getNestableProperty(nestedBean, property.substring(dotIndex+1));
  }else{
    int arrayIndex = Integer.parseInt(property.substring(index1 + 1, property.length() - 2));
    return getArrayProperty(nestedBean, arrayIndex);
origin: org.leapframework/leap-lang

public static Object getNestableProperty(Object bean,String property){
  if(bean instanceof Map){
    return getNestableProperty((Map)bean, property);
  }else if(bean instanceof DynaBean){
    return getNestableProperty(((DynaBean) bean).getProperties(), property);
  }else{
    return getNestableProperty(BeanType.of(bean.getClass()), bean, property);
  }
}

origin: org.leapframework/leap-lang

  return getNestedProperty(beanType, bean, bp, property.substring(dotIndex+1));
}else if(property.charAt(property.length() - 1) == ']'){
  int index1 = property.indexOf('[');
    }else{
      int arrayIndex = Integer.parseInt(property.substring(index1 + 1, property.length() - 2));
      return getArrayProperty(nestedBean, arrayIndex);
origin: org.leapframework/leap-lang

private List<KV> flat(){
  List<KV> flat = new ArrayList<>();
  list.forEach(kv -> {
    String key = kv.key;
    Object value = kv.value;
    if(value == null || Beans.isSimpleProperty(value.getClass())){
      flat.add(new KV(key,value));
    }else {
      JsonObject json = JsonObject.of(JSON.decodeMap(JSON.encode(value)));
      addFlatList(key,json,flat);
    }
  });
  return flat;
}
origin: org.leapframework/leap-lang

protected static Object getNestedMapProperty(BeanType beanType,Object bean,BeanProperty bp,String nestedProperty) {
  Map map = (Map)bp.getValue(bean);
  if(null == map){
    return null;
  }
  
  if(map.containsKey(nestedProperty)){
    return map.get(nestedProperty);
  }
  
  return getNestableProperty(map,nestedProperty);
}

origin: org.leapframework/jmms-modules-redis

public Map<String, String> hencode(Object o) {
  Map<String, Object> map = Beans.toMap(o);
  Map<String, String> hash = new LinkedHashMap<>(map.size());
  map.forEach((k,v) -> {
    hash.put(k, encode(v));
  });
  return hash;
}
origin: org.leapframework/leap-lang

public static <T> T copyNew(T from) {
  if(null == from) {
    return null;
  }
  T to = (T)Reflection.newInstance(from.getClass());
  copyProperties(from, to);
  return to;
}

origin: org.leapframework/leap-lang

  private void addFlatList(String key, JsonObject json, List<KV> flat){
    json.forEachProperty((s,o) ->{
      if(null == o){
        flat.add(new KV(key+"."+s,null));
        return;
      }
      if(Beans.isSimpleProperty(o.getClass())){
        flat.add(new KV(key+"."+s,o));
        return;
      }
      if(o.getClass().isArray()){
        Object[] arrays = (Object[])o;
        for (int i = 0; i < arrays.length; i ++){
          addFlatList(key+"." + s + "["+i+"]",json.getObject(s),flat);
        }
        return;
      }
      if(o instanceof List){
        List arrays = (List) o;
        for (int i = 0; i < arrays.size(); i ++){
          addFlatList(key+"." + s + "["+i+"]",json.getObject(s),flat);
        }
        return;
      }
      addFlatList(key+"."+s,json.getObject(s),flat);
    });
  }
}
origin: org.leapframework/leap-core

protected Object resolveVariableProperty(String key,String variable){
  int dotIndex = key.indexOf('.');
  
  if(dotIndex == Arrays2.INDEX_NOT_FOUND){
    return null;
  }
  
  String prefix = key.substring(0,dotIndex);
  VariableDefinition vd = variables.get(prefix);
  
  if(null == vd){
    return null;
  }else{
    Object value = resolveVariable(vd, null);
    if(null == value){
      return null;
    }else if(value instanceof PropertyGetter){
      return ((PropertyGetter) value).getProperty(variable.substring(dotIndex + 1));
    }else{
      return Beans.getNestableProperty(value,variable.substring(dotIndex + 1));
    }
  }
}

origin: org.leapframework/jmms-core

public int update(Object record, Object id) {
  if(null == id) {
    return dao.update(em, record);
  }else {
    return dao.update(em, id, Beans.toMap(record));
  }
}
origin: org.leapframework/leap-oauth2

@Override
public AuthzClient loadClient(String clientId) {
  AuthzClient authzClient = clients.get(clientId);
  SimpleAuthzClient client = new SimpleAuthzClient();
  Beans.copyProperties(authzClient,client);
  return  client;
}
origin: org.leapframework/leap-core

if(Beans.isSimpleProperty(beanType)){
  return null;
if(Beans.isSimpleProperty(beanType)){
  return null;
origin: org.leapframework/leap-orm

@Override
public int executeNamedUpdate(String sqlKey, Object bean) {
  return ensureGetSqlCommand(sqlKey).executeUpdate(simpleSqlContext, Beans.toMap(bean));
}
origin: org.leapframework/jmms-core

public MetaFormat copyNew() {
  MetaFormat n = new MetaFormat();
  Beans.copyProperties(this, n);
  return n;
}
origin: org.leapframework/leap-orm

public static Object[] getIdArgs(EntityMapping em, Object id) {
  if(id instanceof Object[]) {
    return (Object[])id;
  }
  if(id instanceof Collection) {
    return ((Collection)id).toArray();
  }
  if(em.getKeyColumnNames().length > 1) {
    Map map;
    if(id instanceof Map) {
      map = (Map)id;
    }else {
      map = Beans.toMap(id);
    }
    List<Object> args = new ArrayList<>();
    for(String name : em.getKeyFieldNames()) {
      args.add(map.get(name));
    }
    return args.toArray();
  }else {
    return new Object[]{id};
  }
}

leap.langBeans

Javadoc

java bean utils

Most used methods

  • copyProperties
  • toMap
  • isSimpleProperty
    Check if the given type represents a "simple" property: a primitive, a String or other CharSequence,
  • getNestableProperty
  • getArrayProperty
  • getNestedMapProperty
  • getNestedProperty
  • getProperty
  • setArrayProperty
  • setNestedMapProperty
  • setNestedProperty
  • setPropertiesNestable
  • setNestedProperty,
  • setPropertiesNestable,
  • setPropertiesNestableInternal,
  • setProperty,
  • tryIncreaseSize

Popular in Java

  • Creating JSON documents from java classes using gson
  • getExternalFilesDir (Context)
  • onRequestPermissionsResult (Fragment)
  • findViewById (Activity)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Reference (javax.naming)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now