本文整理匯總了Java中org.yaml.snakeyaml.TypeDescription.putListPropertyType方法的典型用法代碼示例。如果您正苦於以下問題:Java TypeDescription.putListPropertyType方法的具體用法?Java TypeDescription.putListPropertyType怎麽用?Java TypeDescription.putListPropertyType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.yaml.snakeyaml.TypeDescription
的用法示例。
在下文中一共展示了TypeDescription.putListPropertyType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newYaml
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的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);
}
示例2: testLoadList2
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
/**
* explicit TypeDescription is more important then runtime class (which may
* be an interface)
*/
public void testLoadList2() {
String output = Util.getLocalResource("examples/list-bean-3.yaml");
// System.out.println(output);
TypeDescription descr = new TypeDescription(ListBean.class);
descr.putListPropertyType("developers", Developer.class);
Yaml beanLoader = new Yaml(new Constructor(descr));
ListBean parsed = beanLoader.loadAs(output, ListBean.class);
assertNotNull(parsed);
List<Human> developers = parsed.getDevelopers();
assertEquals(2, developers.size());
assertEquals("Committer must be recognised.", Developer.class, developers.get(0).getClass());
Developer fred = (Developer) developers.get(0);
assertEquals("Fred", fred.getName());
assertEquals("creator", fred.getRole());
Developer john = (Developer) developers.get(1);
assertEquals("John", john.getName());
assertEquals("committer", john.getRole());
}
示例3: testChildrenArray
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
public void testChildrenArray() {
Constructor constructor = new Constructor(Human_WithArrayOfChildren.class);
TypeDescription HumanWithChildrenArrayDescription = new TypeDescription(
Human_WithArrayOfChildren.class);
HumanWithChildrenArrayDescription.putListPropertyType("children",
Human_WithArrayOfChildren.class);
constructor.addTypeDescription(HumanWithChildrenArrayDescription);
Human_WithArrayOfChildren son = createSon();
Yaml yaml = new Yaml(constructor);
String output = yaml.dump(son);
// System.out.println(output);
String etalon = Util.getLocalResource("recursive/with-childrenArray.yaml");
assertEquals(etalon, output);
//
Human_WithArrayOfChildren son2 = (Human_WithArrayOfChildren) yaml.load(output);
checkSon(son2);
}
示例4: testArrayAsListValueWithTypeDespriptor
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
public void testArrayAsListValueWithTypeDespriptor() {
Yaml yaml2dump = new Yaml();
yaml2dump.setBeanAccess(BeanAccess.FIELD);
B data = createB();
String dump = yaml2dump.dump(data);
// System.out.println(dump);
TypeDescription aTypeDescr = new TypeDescription(B.class);
aTypeDescr.putListPropertyType("meta", String[].class);
Constructor c = new Constructor();
c.addTypeDescription(aTypeDescr);
Yaml yaml2load = new Yaml(c);
yaml2load.setBeanAccess(BeanAccess.FIELD);
B loaded = (B) yaml2load.load(dump);
Assert.assertArrayEquals(data.meta.toArray(), loaded.meta.toArray());
}
示例5: testLoadList2
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
/**
* explicit TypeDescription is more important then runtime class (which may be
* an interface)
*/
public void testLoadList2() {
String output = Util.getLocalResource("examples/list-bean-3.yaml");
// System.out.println(output);
TypeDescription descr = new TypeDescription(ListBean.class);
descr.putListPropertyType("developers", Developer.class);
Yaml beanLoader = new Yaml(new Constructor(descr));
ListBean parsed = beanLoader.loadAs(output, ListBean.class);
assertNotNull(parsed);
List<Human> developers = parsed.getDevelopers();
assertEquals(2, developers.size());
assertEquals("Committer must be recognised.", Developer.class, developers
.get(0).getClass());
Developer fred = (Developer) developers.get(0);
assertEquals("Fred", fred.getName());
assertEquals("creator", fred.getRole());
Developer john = (Developer) developers.get(1);
assertEquals("John", john.getName());
assertEquals("committer", john.getRole());
}
示例6: init
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
@PostConstruct
public void init() {
try {
Constructor constructor = new Constructor(VariableConfig.class);
TypeDescription variableConfigTypeDescription = new TypeDescription(VariableConfig.class);
variableConfigTypeDescription.putListPropertyType(PROPERTY_VARIABLE_GROUPS, VariableGroup.class);
constructor.addTypeDescription(variableConfigTypeDescription);
TypeDescription variableGroupTypeDescription = new TypeDescription(VariableGroup.class);
variableGroupTypeDescription.putListPropertyType(PROPERTY_VARIABLES, Variable.class);
constructor.addTypeDescription(variableGroupTypeDescription);
Yaml yaml = new Yaml(constructor);
File terraformFolder = resourceService.getClasspathResource(Constants.FOLDER_TERRAFORM);
if (!terraformFolder.isFile()) {
File[] providerFolderArray = terraformFolder.listFiles();
for (File providerFolder : providerFolderArray) {
File variableFile = new File(new URI(providerFolder.toURI() + File.separator + FILE_VARIABLES_YML));
if (variableFile.exists()) {
VariableConfig variableConfig = yaml.loadAs(new FileInputStream(variableFile), VariableConfig.class);
List<VariableGroup> variableGroupList = variableConfig.getVariableGroups();
providerDefaults.put(providerFolder.getName(), variableGroupList);
}
}
}
}
catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
示例7: testParseChildrenArrayWithoutRootTag
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
public void testParseChildrenArrayWithoutRootTag() {
Constructor constructor = new Constructor(Human_WithArrayOfChildren.class);
TypeDescription HumanWithChildrenArrayDescription = new TypeDescription(
Human_WithArrayOfChildren.class);
HumanWithChildrenArrayDescription.putListPropertyType("children",
Human_WithArrayOfChildren.class);
constructor.addTypeDescription(HumanWithChildrenArrayDescription);
Yaml yaml = new Yaml(constructor);
String doc = Util.getLocalResource("recursive/with-childrenArray-no-root-tag.yaml");
Human_WithArrayOfChildren son2 = (Human_WithArrayOfChildren) yaml.load(doc);
checkSon(son2);
}
示例8: testTypeSafeList
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
public void testTypeSafeList() {
Constructor constructor = new Constructor(Car.class);
TypeDescription carDescription = new TypeDescription(Car.class);
carDescription.putListPropertyType("wheels", Wheel.class);
constructor.addTypeDescription(carDescription);
Yaml yaml = new Yaml(constructor);
Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-no-root-class.yaml"));
assertEquals("12-XP-F4", car.getPlate());
List<Wheel> wheels = car.getWheels();
assertNotNull(wheels);
assertEquals(5, wheels.size());
for (Wheel wheel : wheels) {
assertTrue(wheel.getId() > 0);
}
}
示例9: getYamlConstructor
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
private static Constructor getYamlConstructor() {
Constructor constructor = new Constructor(TestConfiguration.class);
TypeDescription testConfigurationTypeDescription = new TypeDescription(TestConfiguration.class);
TypeDescription groupTypeDescription = new TypeDescription(Group.class);
TypeDescription testCaseTypeDescription = new TypeDescription(TestCase.class);
TypeDescription requestTypeDescription = new TypeDescription(RequestDefinition.class);
TypeDescription responseTypeDescription = new TypeDescription(ResponseDefinition.class);
TypeDescription retryStrategyTypeDescription = new TypeDescription(Retry.class);
testConfigurationTypeDescription.putListPropertyType("groups", Group.class);
groupTypeDescription.putListPropertyType("test", TestCase.class);
testCaseTypeDescription.putListPropertyType("retry", Retry.class);
testCaseTypeDescription.putListPropertyType("request", RequestDefinition.class);
testCaseTypeDescription.putListPropertyType("response", ResponseDefinition.class);
requestTypeDescription.putMapPropertyType("headers", String.class, String.class);
responseTypeDescription.putMapPropertyType("headers", String.class, String.class);
constructor.addTypeDescription(testConfigurationTypeDescription);
constructor.addTypeDescription(groupTypeDescription);
constructor.addTypeDescription(testCaseTypeDescription);
constructor.addTypeDescription(retryStrategyTypeDescription);
constructor.addTypeDescription(requestTypeDescription);
constructor.addTypeDescription(responseTypeDescription);
return constructor;
}
示例10: read
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
/**
* Read configuration from a file into a new {@link Settings} object.
*
* @param stream an input stream containing a Gremlin Server YAML configuration
*/
public static Settings read(final InputStream stream) {
Objects.requireNonNull(stream);
final Constructor constructor = new Constructor(Settings.class);
final TypeDescription settingsDescription = new TypeDescription(Settings.class);
settingsDescription.putListPropertyType("hosts", String.class);
settingsDescription.putListPropertyType("serializers", SerializerSettings.class);
constructor.addTypeDescription(settingsDescription);
final Yaml yaml = new Yaml(constructor);
return yaml.loadAs(stream, Settings.class);
}
示例11: getYamlConstructor
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
/**
* Defines how to construct a Workflow objects when reading from YAML
*
* @return A snakeyaml Constructor instance that will be used to create Workflow objects
*/
public static Constructor getYamlConstructor() {
Constructor workflowConstructor = new Constructor(Workflow.class);
TypeDescription workflowDescription = new TypeDescription(Workflow.class);
workflowDescription.putListPropertyType("actions", Action.class);
workflowConstructor.addTypeDescription(workflowDescription);
return workflowConstructor;
}
示例12: getYamlConstructor
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
/**
* Defines how to construct a Config objects when reading from YAML
*
* @return A snakeyaml Constructor instance that will be used to create Config objects
*/
public static Constructor getYamlConstructor() {
Constructor configConstructor = new Constructor(Config.class);
TypeDescription configDescription = new TypeDescription(Config.class);
configDescription.putListPropertyType("actionTypes", ActionType.class);
configConstructor.addTypeDescription(configDescription);
return configConstructor;
}
示例13: topologyYaml
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
private static Yaml topologyYaml() {
Constructor topologyConstructor = new Constructor(EcoTopologyDefinition.class);
TypeDescription topologyDescription = new TypeDescription(EcoTopologyDefinition.class);
topologyDescription.putListPropertyType("spouts", SpoutDefinition.class);
topologyDescription.putListPropertyType("bolts", BoltDefinition.class);
topologyConstructor.addTypeDescription(topologyDescription);
return new Yaml(topologyConstructor);
}
示例14: BundleElementsConstructor
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
public BundleElementsConstructor(File bundleDirectory)
{
this.bundleDirectory = bundleDirectory;
this.yamlConstructors.put(new Tag(SCOPE_SELECTOR_TAG), new ConstructScopeSelector());
this.yamlConstructors.put(new Tag("!ruby/regexp"), new ConstructRubyRegexp()); //$NON-NLS-1$
this.yamlConstructors.put(new Tag(REGEXP_TAG), new ConstructRubyRegexp());
this.yamlConstructors.put(new Tag(COMMAND_TAG), new ConstructCommandElement());
this.yamlConstructors.put(new Tag(ENVIRONMENT_TAG), new ConstructEnvironmentElement());
this.yamlConstructors.put(new Tag(CONTENT_ASSIST_TAG), new ConstructContentAssistElement());
this.yamlConstructors.put(new Tag(TEMPLATE_TAG), new ConstructTemplateElement());
this.yamlConstructors.put(new Tag(BundleElement.class), new ConstructBundleElement());
this.yamlConstructors.put(new Tag(MenuElement.class), new ConstructMenuElement());
this.yamlConstructors.put(new Tag(SnippetElement.class), new ConstructSnippetElement());
this.yamlConstructors.put(new Tag(SnippetCategoryElement.class), new ConstructSnippetCategoryElement());
this.yamlConstructors.put(new Tag(ContentAssistElement.class), new ConstructContentAssistElement());
this.yamlConstructors.put(new Tag(CommandElement.class), new ConstructCommandElement());
this.yamlConstructors.put(new Tag(TemplateElement.class), new ConstructTemplateElement());
this.yamlConstructors.put(new Tag(SmartTypingPairsElement.class), new ConstructSmartTypingPairsElement());
this.yamlConstructors.put(new Tag(ProjectTemplateElement.class), new ConstructProjectTemplateElement());
this.yamlConstructors.put(new Tag(ProjectSampleElement.class), new ConstructProjectSampleElement());
this.yamlConstructors.put(new Tag(EnvironmentElement.class), new ConstructEnvironmentElement());
this.yamlConstructors.put(new Tag(BuildPathElement.class), new ConstructBuildPathElement());
// Tell it that "children" field for MenuElement is a list of MenuElements
TypeDescription menuDescription = new TypeDescription(MenuElement.class);
menuDescription.putListPropertyType("children", MenuElement.class); //$NON-NLS-1$
addTypeDescription(menuDescription);
}
示例15: deserialize
import org.yaml.snakeyaml.TypeDescription; //導入方法依賴的package包/類
public static ConfigurationStream deserialize(InputStream inputStream) {
if (yaml == null) {
synchronized (ConfigurationStream.class) {
if (yaml == null) {
Constructor ctor = new Constructor(ConfigurationStream.class);
TypeDescription cfgsDescription = new TypeDescription(ConfigurationStream.class);
cfgsDescription.putListPropertyType("configurations", ConfigurationInstance.class);
ctor.addTypeDescription(cfgsDescription);
yaml = new Yaml(ctor);
}
}
}
return (ConfigurationStream) yaml.load(inputStream);
}