本文整理了Java中groovy.lang.MetaClass.getProperties()
方法的一些代码示例,展示了MetaClass.getProperties()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaClass.getProperties()
方法的具体详情如下:
包路径:groovy.lang.MetaClass
类名称:MetaClass
方法名:getProperties
[英]Retrives a list of MetaProperty instances that the MetaClass has
[中]检索元类拥有的元属性实例列表
代码示例来源:origin: org.codehaus.groovy/groovy
public List<MetaProperty> getProperties() {
return delegate.getProperties();
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Returns a string detailing possible solutions to a missing field or property
* if no good solutions can be found a empty string is returned.
*
* @param fieldName the missing field
* @param type the class on which the field is sought
* @return a string with probable solutions to the exception
*/
public static String getPropertySuggestionString(String fieldName, Class type){
ClassInfo ci = ClassInfo.getClassInfo(type);
List<MetaProperty> fi = ci.getMetaClass().getProperties();
List<RankableField> rf = new ArrayList<RankableField>(fi.size());
StringBuilder sb = new StringBuilder();
sb.append("\nPossible solutions: ");
for(MetaProperty mp : fi) rf.add(new RankableField(fieldName, mp));
Collections.sort(rf);
int i = 0;
for (RankableField f : rf) {
if (i > MAX_RECOMENDATIONS) break;
if (f.score > MAX_FIELD_SCORE) break;
if(i > 0) sb.append(", ");
sb.append(f.f.getName());
i++;
}
return i > 0? sb.toString(): "";
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Retrieves the list of {@link groovy.lang.MetaProperty} objects for 'self' and wraps it
* in a list of {@link groovy.lang.PropertyValue} objects that additionally provide
* the value for each property of 'self'.
*
* @param self the receiver object
* @return list of {@link groovy.lang.PropertyValue} objects
* @see groovy.util.Expando#getMetaPropertyValues()
* @since 1.0
*/
public static List<PropertyValue> getMetaPropertyValues(Object self) {
MetaClass metaClass = InvokerHelper.getMetaClass(self);
List<MetaProperty> mps = metaClass.getProperties();
List<PropertyValue> props = new ArrayList<PropertyValue>(mps.size());
for (MetaProperty mp : mps) {
props.add(new PropertyValue(self, mp));
}
return props;
}
代码示例来源:origin: org.codehaus.groovy/groovy
public List<MetaProperty> getProperties() {
final Object owner = getOwner();
final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
return ownerMetaClass.getProperties();
}
代码示例来源:origin: org.codehaus.groovy/groovy
final List<MetaProperty> propList = metaClass.getProperties();
for (MetaProperty prop : propList)
if (self.getMetaProperty(prop.getName()) == null) {
代码示例来源:origin: lenskit/lenskit
public void apply(Project project) {
final LenskitExtension lenskit = project.getExtensions().create("lenskit", LenskitExtension.class, project);
for (MetaProperty prop : DefaultGroovyMethods.getMetaClass(lenskit).getProperties()) {
String prjProp = "lenskit." + prop.getName();
if (project.hasProperty(prjProp)) {
代码示例来源:origin: org.gmock/gmock
public List getProperties() {
return adaptee.getProperties();
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
public List getProperties() {
return delegate.getProperties();
}
/* (non-Javadoc)
代码示例来源:origin: org.kohsuke.droovy/groovy
public List getProperties() {
return delegate.getProperties();
}
/* (non-Javadoc)
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
public List<MetaProperty> getProperties() {
return delegate.getProperties();
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
public List<MetaProperty> getProperties() {
return delegate.getProperties();
}
代码示例来源:origin: org.kohsuke.droovy/groovy
/**
* Retrieves the list of {@link MetaProperty} objects for 'self' and wraps it
* in a list of {@link PropertyValue} objects that additionally provide
* the value for each property of 'self'.
*
* @param self the receiver object
* @return list of {@link PropertyValue} objects
* @see groovy.util.Expando#getMetaPropertyValues()
* @since 1.0
*/
public static List getMetaPropertyValues(Object self) {
MetaClass metaClass = InvokerHelper.getMetaClass(self);
List mps = metaClass.getProperties();
List props = new ArrayList(mps.size());
for (Iterator itr = mps.iterator(); itr.hasNext();) {
MetaProperty mp = (MetaProperty) itr.next();
PropertyValue pv = new PropertyValue(self, mp);
props.add(pv);
}
return props;
}
代码示例来源:origin: org.grails/grails-datastore-core
@SuppressWarnings("unchecked")
public List<PropertyDescriptor> getPropertiesAssignableToType(Class assignableType) {
List<MetaProperty> properties = theMetaClass.getProperties();
List<PropertyDescriptor> propertyDescriptors = new ArrayList<>(2);
for (MetaProperty property : properties) {
int modifiers = property.getModifiers();
if(Modifier.isStatic(modifiers) || property.getName().contains("$") || !assignableType.isAssignableFrom(property.getType())) {
continue;
}
addBeanProperty(propertyDescriptors, property);
}
return propertyDescriptors;
}
代码示例来源:origin: org.grails/grails-datastore-core
public List<PropertyDescriptor> getPropertiesOfType(Class javaClass) {
List<MetaProperty> properties = theMetaClass.getProperties();
List<PropertyDescriptor> propertyDescriptors = new ArrayList<>(2);
for (MetaProperty property : properties) {
int modifiers = property.getModifiers();
if(Modifier.isStatic(modifiers) || property.getName().contains("$") || !property.getType().equals(javaClass)) continue;
addBeanProperty(propertyDescriptors, property);
}
return propertyDescriptors;
}
代码示例来源:origin: org.grails/grails-datastore-core
@SuppressWarnings("unchecked")
public List<PropertyDescriptor> getPropertiesAssignableFromType(Class assignableType) {
List<MetaProperty> properties = theMetaClass.getProperties();
List<PropertyDescriptor> propertyDescriptors = new ArrayList<>(2);
for (MetaProperty property : properties) {
int modifiers = property.getModifiers();
if(Modifier.isStatic(modifiers) || property.getName().contains("$") || !property.getType().isAssignableFrom( assignableType )) continue;
addBeanProperty(propertyDescriptors, property);
}
return propertyDescriptors;
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
/**
* Retrieves the list of {@link MetaProperty} objects for 'self' and wraps it
* in a list of {@link PropertyValue} objects that additionally provide
* the value for each property of 'self'.
*
* @param self the receiver object
* @return list of {@link PropertyValue} objects
* @see groovy.util.Expando#getMetaPropertyValues()
* @since 1.0
*/
public static List<PropertyValue> getMetaPropertyValues(Object self) {
MetaClass metaClass = InvokerHelper.getMetaClass(self);
List<MetaProperty> mps = metaClass.getProperties();
List<PropertyValue> props = new ArrayList<PropertyValue>(mps.size());
for (MetaProperty mp : mps) {
props.add(new PropertyValue(self, mp));
}
return props;
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
public List<MetaProperty> getProperties() {
final Object owner = getOwner();
final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
return ownerMetaClass.getProperties();
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
public List<MetaProperty> getProperties() {
final Object owner = getOwner();
final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
return ownerMetaClass.getProperties();
}
代码示例来源:origin: org.kohsuke.droovy/groovy
public List getProperties() {
final Object owner = getOwner();
final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
return ownerMetaClass.getProperties();
}
代码示例来源:origin: com.mgmtp.jfunk/jfunk-core
private void initGroovyCommands(final ScriptEngine scriptEngine, final ScriptContext scriptContext) {
Commands commands = new Commands(scriptContext);
for (MetaProperty mp : commands.getMetaClass().getProperties()) {
String propertyType = mp.getType().getCanonicalName();
String propertyName = mp.getName();
if (propertyType.equals(groovy.lang.Closure.class.getCanonicalName())) {
scriptEngine.put(propertyName, commands.getProperty(propertyName));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!