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

  • Making http post requests using okhttp
  • startActivity (Activity)
  • onRequestPermissionsResult (Fragment)
  • setContentView (Activity)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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