本文整理了Java中groovy.lang.MetaClass.hasProperty()
方法的一些代码示例,展示了MetaClass.hasProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaClass.hasProperty()
方法的具体详情如下:
包路径:groovy.lang.MetaClass
类名称:MetaClass
方法名:hasProperty
暂无
代码示例来源:origin: org.codehaus.groovy/groovy
public MetaProperty hasProperty(Object obj, String name) {
return delegate.hasProperty(obj, name);
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* <p>Returns true of the implementing MetaClass has a property of the given name
*
* <p>Note that this method will only return true for realised properties and does not take into
* account implementation of getProperty or propertyMissing
*
* @param self The object to inspect
* @param name The name of the property of interest
* @return The found MetaProperty or null if it doesn't exist
* @see groovy.lang.MetaObjectProtocol#hasProperty(java.lang.Object, java.lang.String)
* @since 1.6.1
*/
public static MetaProperty hasProperty(Object self, String name) {
return InvokerHelper.getMetaClass(self).hasProperty(self, name);
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Handles the common English regular plurals with the following rules.
* <ul>
* <li>If childName ends in {consonant}y, replace 'y' with "ies". For example, allergy to allergies.</li>
* <li>Otherwise, append 's'. For example, monkey to monkeys; employee to employees.</li>
* </ul>
* If the property does not exist then it will return childName unchanged.
*
* @see <a href="http://en.wikipedia.org/wiki/English_plural">English_plural</a>
*/
public String resolveChildRelationName(String parentName, Object parent, String childName,
Object child) {
boolean matchesIESRule = PLURAL_IES_PATTERN.matcher(childName).matches();
String childNamePlural = matchesIESRule ? childName.substring(0, childName.length() - 1) + "ies" : childName + "s";
MetaProperty metaProperty = InvokerHelper.getMetaClass(parent)
.hasProperty(parent, childNamePlural);
return metaProperty != null ? childNamePlural : childName;
}
代码示例来源:origin: org.codehaus.groovy/groovy
public static void checkPropNames(Object instance, Map<String, Object> args) {
final MetaClass metaClass = InvokerHelper.getMetaClass(instance);
for (String k : args.keySet()) {
if (metaClass.hasProperty(instance, k) == null)
throw new MissingPropertyException(k, instance.getClass());
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
public Object getProperty(String property) {
if(ExpandoMetaClass.isValidExpandoProperty(property)) {
if(property.equals(ExpandoMetaClass.STATIC_QUALIFIER) ||
property.equals(ExpandoMetaClass.CONSTRUCTOR) ||
Holder.META_CLASS.hasProperty(this, property) == null) {
return replaceDelegate().getProperty(property);
}
}
return Holder.META_CLASS.getProperty(this, property);
}
代码示例来源:origin: org.codehaus.groovy/groovy
public MetaProperty hasProperty(Object obj, String name) {
final Object owner = getOwner();
final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
return ownerMetaClass.hasProperty(owner, name);
}
代码示例来源:origin: org.codehaus.groovy/groovy
public Object getProperty(String property) {
if (isValidExpandoProperty(property)) {
if (property.equals(STATIC_QUALIFIER)) {
return new ExpandoMetaProperty(property, true);
} else if (property.equals(CONSTRUCTOR)) {
return new ExpandoMetaConstructor();
} else {
if (myMetaClass.hasProperty(this, property) == null)
return new ExpandoMetaProperty(property);
else
return myMetaClass.getProperty(this, property);
}
} else {
return myMetaClass.getProperty(this, property);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
public void setChild(FactoryBuilderSupport builder, Object parent, Object child) {
if (child == null) return;
ObjectGraphBuilder ogbuilder = (ObjectGraphBuilder) builder;
if (parent != null) {
Map context = ogbuilder.getContext();
Map parentContext = ogbuilder.getParentContext();
String parentName = null;
String childName = (String) context.get(NODE_NAME);
if (parentContext != null) {
parentName = (String) parentContext.get(NODE_NAME);
}
String propertyName = ogbuilder.relationNameResolver.resolveParentRelationName(
parentName, parent, childName, child);
MetaProperty metaProperty = InvokerHelper.getMetaClass(child)
.hasProperty(child, propertyName);
if (metaProperty != null) {
metaProperty.setProperty(child, parent);
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
private void resolveLazyReferences() {
if (!lazyReferencesAllowed) return;
for (NodeReference ref : lazyReferences) {
if (ref.parent == null) continue;
Object child = null;
try {
child = getProperty(ref.refId);
} catch (MissingPropertyException mpe) {
// ignore
}
if (child == null) {
throw new IllegalArgumentException("There is no valid node for reference "
+ ref.parentName + "." + ref.childName + "=" + ref.refId);
}
// set child first
childPropertySetter.setChild(ref.parent, child, ref.parentName,
relationNameResolver.resolveChildRelationName(ref.parentName,
ref.parent, ref.childName, child));
// set parent afterwards
String propertyName = relationNameResolver.resolveParentRelationName(ref.parentName,
ref.parent, ref.childName, child);
MetaProperty metaProperty = InvokerHelper.getMetaClass(child)
.hasProperty(child, propertyName);
if (metaProperty != null) {
metaProperty.setProperty(child, ref.parent);
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
final MetaProperty metaProperty = InvokerHelper.getMetaClass(Class.class).hasProperty(instance, propertyName);
if (metaProperty != null)
if (isGetter)
代码示例来源:origin: org.gperfutils/gprof
@Override
public MetaProperty hasProperty(Object obj, String name) {
return adaptee.hasProperty(obj, name);
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
public MetaProperty hasProperty(Object obj, String name) {
return delegate.hasProperty(obj, name);
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
public static void checkPropNames(Object instance, Map<String, Object> args) {
final MetaClass metaClass = InvokerHelper.getMetaClass(instance);
for (String k : args.keySet()) {
if (metaClass.hasProperty(instance, k) == null)
throw new MissingPropertyException(k, instance.getClass());
}
}
}
代码示例来源:origin: org.grails/grails-plugin-converters
public boolean supports(Object object) {
if (object == null) return false;
MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(object.getClass());
return mc.hasProperty(object, HIBERNATE_LAZY_INITIALIZER_PROP) != null;
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
public Object getProperty(String property) {
if(ExpandoMetaClass.isValidExpandoProperty(property)) {
if(property.equals(ExpandoMetaClass.STATIC_QUALIFIER) ||
property.equals(ExpandoMetaClass.CONSTRUCTOR) ||
myMetaClass.hasProperty(this, property) == null) {
return replaceDelegate().getProperty(property);
}
}
return myMetaClass.getProperty(this, property);
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
public Object getProperty(String property) {
if(ExpandoMetaClass.isValidExpandoProperty(property)) {
if(property.equals(ExpandoMetaClass.STATIC_QUALIFIER) ||
property.equals(ExpandoMetaClass.CONSTRUCTOR) ||
myMetaClass.hasProperty(this, property) == null) {
return replaceDelegate().getProperty(property);
}
}
return myMetaClass.getProperty(this, property);
}
代码示例来源:origin: org.kohsuke.droovy/groovy
public Object getProperty(String property) {
if(ExpandoMetaClass.isValidExpandoProperty(property)) {
if(property.equals(ExpandoMetaClass.STATIC_QUALIFIER) ||
property.equals(ExpandoMetaClass.CONSTRUCTOR) ||
myMetaClass.hasProperty(this, property) == null) {
return replaceDelegate().getProperty(property);
}
}
return myMetaClass.getProperty(this, property);
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
public MetaProperty hasProperty(Object obj, String name) {
final Object owner = getOwner();
final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
return ownerMetaClass.hasProperty(owner, name);
}
代码示例来源:origin: org.kohsuke.droovy/groovy
public MetaProperty hasProperty(Object obj, String name) {
final Object owner = getOwner();
final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
return ownerMetaClass.hasProperty(owner, name);
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
public MetaProperty hasProperty(Object obj, String name) {
final Object owner = getOwner();
final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
return ownerMetaClass.hasProperty(owner, name);
}
内容来源于网络,如有侵权,请联系作者删除!