org.apache.openjpa.lib.util.Options.setInto()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(133)

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

Options.setInto介绍

[英]This method uses reflection to set all the properties in the given object that are named by the keys in this map. For a given key 'foo', the algorithm will look for a 'setFoo' method in the given instance. For a given key 'foo.bar', the algorithm will first look for a 'getFoo' method in the given instance, then will recurse on the return value of that method, now looking for the 'bar' property. This allows the setting of nested object properties. If in the above example the 'getFoo' method is not present or returns null, the algorithm will look for a 'setFoo' method; if found it will constrct a new instance of the correct type, set it using the 'setFoo' method, then recurse on it as above. Property names can be nested in this way to an arbitrary depth. For setter methods that take multiple parameters, the value mapped to the key can use the ',' as an argument separator character. If not enough values are present for a given method after splitting the string on ',', the remaining arguments will receive default values. All arguments are converted from string form to the correct type if possible(i.e. if the type is primitive, java.lang.Clas, or has a constructor that takes a single string argument). Examples:

  • Map Entry: "age"->"12"
    Resultant method call: obj.setAge(12)
  • Map Entry: "range"->"1,20"
    Resultant method call: obj.setRange(1, 20)
  • Map Entry: "range"->"10"
    Resultant method call: obj.setRange(10, 10)
  • Map Entry: "brother.name"->"Bob"
    Resultant method call: obj.getBrother().setName("Bob") [[$7$]]
    Any keys present in the map for which there is no corresponding property in the given object will be ignored, and will be returned in the Map returned by this method.
    [中]此方法使用反射来设置给定对象中由该贴图中的键命名的所有属性。对于给定的键“foo”,算法将在给定实例中查找“setFoo”方法。对于给定的键“foo”。bar’算法将首先在给定实例中查找“getFoo”方法,然后根据该方法的返回值递归,现在查找“bar”属性。这允许设置嵌套对象属性。如果在上面的示例中“getFoo”方法不存在或返回null,则算法将查找“setFoo”方法;如果发现它将构造一个正确类型的新实例,请使用“setFoo”方法设置它,然后如上所述在其上递归。属性名称可以以这种方式嵌套到任意深度。对于采用多个参数的setter方法,映射到键的值可以使用“,”作为参数分隔符。如果在“,”上拆分字符串后,给定方法没有足够的值,其余参数将接收默认值。如果可能的话,所有参数都会从字符串形式转换为正确的类型(即,如果类型是primitive、java.lang.Clas或具有接受单个字符串参数的构造函数)。例如:
    *地图条目:"age"->"12"
    结果方法调用:obj.setAge(12)
    *地图条目:"range"->"1,20"
    结果方法调用:obj.setRange(1, 20)
    *地图条目:"range"->"10"
    结果方法调用:obj.setRange(10, 10)
    *地图条目:"brother.name"->"Bob"
    结果方法调用:obj.getBrother().setName("Bob") [[$7$]]
    在给定对象中没有相应属性的映射中存在的任何键都将被忽略,并将在该方法返回的映射中返回。

代码示例

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

public void setInto(Options opts) {
  opts.keySet().retainAll(opts.setInto(_def).keySet());
}

代码示例来源:origin: org.apache.openjpa/openjpa-persistence

public void setInto(Options opts) {
  opts.keySet().retainAll(opts.setInto(_def).keySet());
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

public void setInto(Options opts) {
  opts.keySet().retainAll(opts.setInto(_def).keySet());
}

代码示例来源:origin: org.apache.openejb.patch/openjpa-persistence

public void setInto(Options opts) {
  opts.keySet().retainAll(opts.setInto(_def).keySet());
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

public void setInto(Options opts) {
  opts.keySet().retainAll(opts.setInto(_def).keySet());
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

entry = (Map.Entry) itr.next();
    if (!containsKey(entry.getKey()))
      setInto(obj, entry);
for (Iterator<?> itr = entrySet().iterator(); itr.hasNext();) {
  e = (Map.Entry) itr.next();
  if (!setInto(obj, e)) {
    if (invalidEntries == null)
      invalidEntries = new Options();

代码示例来源:origin: org.apache.openjpa/openjpa-all

entry = (Map.Entry) itr.next();
    if (!containsKey(entry.getKey()))
      setInto(obj, entry);
for (Iterator<?> itr = entrySet().iterator(); itr.hasNext();) {
  e = (Map.Entry) itr.next();
  if (!setInto(obj, e)) {
    if (invalidEntries == null)
      invalidEntries = new Options();

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

provider.setInto(conf);
opts.setInto(conf);

代码示例来源:origin: org.apache.openejb.patch/openjpa

provider.setInto(conf);
opts.setInto(conf);

代码示例来源:origin: org.apache.openjpa/openjpa-all

provider.setInto(conf);
opts.setInto(conf);

代码示例来源:origin: org.apache.openjpa/openjpa-lib

provider.setInto(conf);
opts.setInto(conf);

代码示例来源:origin: org.apache.openejb.patch/openjpa-kernel

formatOpts.setInto(flags.format);

代码示例来源:origin: org.apache.openejb.patch/openjpa

formatOpts.setInto(flags.format);

代码示例来源:origin: org.apache.openjpa/openjpa-kernel

formatOpts.setInto(flags.format);

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

formatOpts.setInto(flags.format);

代码示例来源:origin: org.apache.openjpa/openjpa-all

formatOpts.setInto(flags.format);

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

configurable.startConfiguration();
Options invalidEntries = opts.setInto(obj);
if (obj instanceof GenericConfigurable)
  ((GenericConfigurable) obj).setInto(invalidEntries);

代码示例来源:origin: org.apache.openjpa/openjpa-all

configurable.startConfiguration();
Options invalidEntries = opts.setInto(obj);
if (obj instanceof GenericConfigurable)
  ((GenericConfigurable) obj).setInto(invalidEntries);

代码示例来源:origin: org.apache.openejb.patch/openjpa

configurable.startConfiguration();
Options invalidEntries = opts.setInto(obj);
if (obj instanceof GenericConfigurable)
  ((GenericConfigurable) obj).setInto(invalidEntries);

代码示例来源:origin: org.apache.openjpa/openjpa-lib

configurable.startConfiguration();
Options invalidEntries = opts.setInto(obj);
if (obj instanceof GenericConfigurable)
  ((GenericConfigurable) obj).setInto(invalidEntries);

相关文章