當前位置: 首頁>>代碼示例>>Java>>正文


Java Constructor.setPropertyUtils方法代碼示例

本文整理匯總了Java中org.yaml.snakeyaml.constructor.Constructor.setPropertyUtils方法的典型用法代碼示例。如果您正苦於以下問題:Java Constructor.setPropertyUtils方法的具體用法?Java Constructor.setPropertyUtils怎麽用?Java Constructor.setPropertyUtils使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.yaml.snakeyaml.constructor.Constructor的用法示例。


在下文中一共展示了Constructor.setPropertyUtils方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadYaml

import org.yaml.snakeyaml.constructor.Constructor; //導入方法依賴的package包/類
private Object loadYaml(File omapfile) throws IOException {
    FileReader reader = new FileReader(omapfile);
    try {
        Constructor constructor = new Constructor();
        PropertyUtils putils = new PropertyUtils();
        putils.setSkipMissingProperties(true);
        constructor.setPropertyUtils(putils);
        Yaml yaml = new Yaml(constructor);
        return yaml.load(reader);
    } catch (Throwable t) {
        throw new RuntimeException("Error loading yaml from: " + omapfile.getAbsolutePath() + "\n" + t.getMessage(), t);
    } finally {
        try {
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:20,代碼來源:ObjectMapItem.java

示例2: loadYaml

import org.yaml.snakeyaml.constructor.Constructor; //導入方法依賴的package包/類
private Object loadYaml(File file) throws FileNotFoundException {
    FileReader reader = new FileReader(file);
    try {
        Constructor constructor = new Constructor();
        PropertyUtils putils = new PropertyUtils();
        putils.setSkipMissingProperties(true);
        constructor.setPropertyUtils(putils);
        Yaml yaml = new Yaml(constructor);
        return yaml.load(reader);
    } catch (Throwable t) {
        throw new RuntimeException("Error loading yaml from: " + file.getAbsolutePath() + "\n" + t.getMessage(), t);
    } finally {
        try {
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:20,代碼來源:OMapContainer.java

示例3: newYaml

import org.yaml.snakeyaml.constructor.Constructor; //導入方法依賴的package包/類
public static Yaml newYaml() {
  PropertyUtils propertyUtils = new AdvancedPropertyUtils();
  propertyUtils.setSkipMissingProperties(true);

  Constructor constructor = new Constructor(Federations.class);
  TypeDescription federationDescription = new TypeDescription(Federations.class);
  federationDescription.putListPropertyType("federatedMetaStores", FederatedMetaStore.class);
  constructor.addTypeDescription(federationDescription);
  constructor.setPropertyUtils(propertyUtils);

  Representer representer = new AdvancedRepresenter();
  representer.setPropertyUtils(new FieldOrderPropertyUtils());
  representer.addClassTag(Federations.class, Tag.MAP);
  representer.addClassTag(AbstractMetaStore.class, Tag.MAP);
  representer.addClassTag(WaggleDanceConfiguration.class, Tag.MAP);
  representer.addClassTag(YamlStorageConfiguration.class, Tag.MAP);
  representer.addClassTag(GraphiteConfiguration.class, Tag.MAP);

  DumperOptions dumperOptions = new DumperOptions();
  dumperOptions.setIndent(2);
  dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK);

  return new Yaml(constructor, representer, dumperOptions);
}
 
開發者ID:HotelsDotCom,項目名稱:waggle-dance,代碼行數:25,代碼來源:YamlFactory.java

示例4: testErrorMessage

import org.yaml.snakeyaml.constructor.Constructor; //導入方法依賴的package包/類
public void testErrorMessage() throws Exception {

        BeanA1 b = new BeanA1();
        b.setId(2l);
        b.setName("name1");

        Constructor c = new Constructor();
        Representer r = new Representer();

        PropertyUtils pu = new PropertyUtils();
        c.setPropertyUtils(pu);
        r.setPropertyUtils(pu);

        pu.getProperties(BeanA1.class, BeanAccess.FIELD);

        Yaml yaml = new Yaml(c, r);
        // yaml.setBeanAccess(BeanAccess.FIELD);
        String dump = yaml.dump(b);
        BeanA1 b2 = (BeanA1) yaml.load(dump);
        assertEquals(b.getId(), b2.getId());
        assertEquals(b.getName(), b2.getName());
    }
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:23,代碼來源:AbstractBeanTest.java

示例5: loadSettings

import org.yaml.snakeyaml.constructor.Constructor; //導入方法依賴的package包/類
/**
 * @author wasiq.bhamla
 * @since 09-Jun-2017 5:00:19 PM
 * @param cls
 */
@SuppressWarnings ("unchecked")
private <T> T loadSettings (final Class <T> cls) {
	final String path = System.getProperty (this.key, this.value);
	try (final InputStream in = getClass ().getResourceAsStream (path)) {
		if (in != null) {
			final Constructor ctor = new Constructor (cls);
			final PropertyUtils propertyUtils = new PropertyUtils () {
				@Override
				public Property getProperty (final Class <? extends Object> obj, final String name) {
					String propertyName = name;
					if (propertyName.indexOf ('_') > -1) {
						propertyName = CaseFormat.LOWER_UNDERSCORE.to (CaseFormat.LOWER_CAMEL, propertyName);
					}
					return super.getProperty (obj, propertyName);
				}
			};
			ctor.setPropertyUtils (propertyUtils);
			final Yaml yaml = new Yaml (ctor);
			return (T) yaml.load (in);
		}
	}
	catch (final Exception e) {
		fail (CoteafsConfigNotLoadedError.class, "Error loading config file.", e);
	}
	final String MSG = "%s not found.";
	fail (CoteafsConfigFileNotFoundError.class, String.format (MSG, path));
	return null;
}
 
開發者ID:WasiqB,項目名稱:coteafs-config,代碼行數:34,代碼來源:ConfigLoader.java

示例6: testYamlConstructorWithPropertyUtils

import org.yaml.snakeyaml.constructor.Constructor; //導入方法依賴的package包/類
public void testYamlConstructorWithPropertyUtils() {
    Constructor constructor1 = new Constructor();
    PropertyUtils pu = new PropertyUtils();
    constructor1.setPropertyUtils(pu);
    Yaml yaml = new Yaml(constructor1);
    assertSame(pu, yaml.constructor.getPropertyUtils());
    assertSame(pu, yaml.representer.getPropertyUtils());
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:9,代碼來源:PropertyUtilsSharingTest.java

示例7: testYamlConstructorANDRepresenterWithPropertyUtils

import org.yaml.snakeyaml.constructor.Constructor; //導入方法依賴的package包/類
@Test
public void testYamlConstructorANDRepresenterWithPropertyUtils() {
    Constructor constructor = new Constructor();
    PropertyUtils pu_c = new PropertyUtils();
    constructor.setPropertyUtils(pu_c);
    Representer representer = new Representer();
    PropertyUtils pu_r = new PropertyUtils();
    representer.setPropertyUtils(pu_r);
    Yaml yaml = new Yaml(constructor, representer);
    assertSame(pu_c, yaml.constructor.getPropertyUtils());
    assertSame(pu_r, yaml.representer.getPropertyUtils());
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:13,代碼來源:PropertyUtilsSharingTest.java

示例8: PluginManager

import org.yaml.snakeyaml.constructor.Constructor; //導入方法依賴的package包/類
public PluginManager(ProxyServer proxy)
{
    this.proxy = proxy;

    // Ignore unknown entries in the plugin descriptions
    Constructor yamlConstructor = new Constructor();
    PropertyUtils propertyUtils = yamlConstructor.getPropertyUtils();
    propertyUtils.setSkipMissingProperties( true );
    yamlConstructor.setPropertyUtils( propertyUtils );
    yaml = new Yaml( yamlConstructor );

    eventBus = new EventBus( proxy.getLogger() );
}
 
開發者ID:WaterfallMC,項目名稱:Waterfall-Old,代碼行數:14,代碼來源:PluginManager.java


注:本文中的org.yaml.snakeyaml.constructor.Constructor.setPropertyUtils方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。