Refine search
private static Yaml yaml() { TypeDescription topologyDescription = new TypeDescription(TopologyDef.class); topologyDescription.putListPropertyType("spouts", SpoutDef.class); topologyDescription.putListPropertyType("bolts", BoltDef.class); topologyDescription.putListPropertyType("includes", IncludeDef.class); Constructor constructor = new Constructor(TopologyDef.class); constructor.addTypeDescription(topologyDescription); Yaml yaml = new Yaml(constructor); return yaml; }
protected void addTypeDescription(Constructor configConstructor) { TypeDescription mapPropertyTypeDesc = new TypeDescription(MapPropertyTypeDef.class); mapPropertyTypeDesc.putMapPropertyType("parameters", String.class, String.class); configConstructor.addTypeDescription(mapPropertyTypeDesc); }
private static <T> T parseObject(String rawConfig) { Constructor constructor = new Constructor(ConfiguratorConfig.class); TypeDescription itemDescription = new TypeDescription(ConfiguratorConfig.class); itemDescription.addPropertyParameters("items", ConfigItem.class); constructor.addTypeDescription(itemDescription); Yaml yaml = new Yaml(constructor); return yaml.load(rawConfig); }
public RecipeConfigParser() { Constructor constructor = new Constructor(Recipe.class); TypeDescription carDescription = new TypeDescription(Recipe.class); constructor.addTypeDescription(carDescription); Yaml yaml = new Yaml(constructor); Recipe recipe = (Recipe) yaml.load("ecommerce_test.yml"); }
public static VNFDTemplate bytesToVNFDTemplate(ByteArrayOutputStream b) { Constructor constructor = new VnfdTemplateConstructor(); TypeDescription projectDesc = new TypeDescription(VNFDTemplate.class); constructor.addTypeDescription(projectDesc); Yaml yaml = new Yaml(constructor); return yaml.loadAs(new ByteArrayInputStream(b.toByteArray()), VNFDTemplate.class); }
public BODODescriptor loadBodoDescriptor() throws IOException { TypeDescription descriptorDescription = new TypeDescription(BODODescriptor.class); descriptorDescription.putListPropertyType("implementations", BODODescriptor.Implementation.class); Yaml yaml = new Yaml(new Constructor(descriptorDescription)); return (BODODescriptor)yaml.load(loadString()); }
desc = new TypeDescription(Model.class); desc.putListPropertyType("licenses", License.class); desc.putListPropertyType("mailingLists", MailingList.class); desc.putListPropertyType("dependencies", Dependency.class); desc.putListPropertyType("modules", String.class); desc.putListPropertyType("profiles", Profile.class); desc.putListPropertyType("repositories", Repository.class); desc.putListPropertyType("pluginRepositories", Repository.class); desc.putListPropertyType("developers", Developer.class); desc.putListPropertyType("contributors", Contributor.class); addTypeDescription(desc); desc = new TypeDescription(Dependency.class); desc.putListPropertyType("exclusions", Exclusion.class); addTypeDescription(desc); desc = new TypeDescription(DependencyManagement.class); desc.putListPropertyType("dependencies", Dependency.class); addTypeDescription(desc); desc = new TypeDescription(Build.class); desc.putListPropertyType("extensions", Extension.class); desc.putListPropertyType("resources", Resource.class); desc.putListPropertyType("testResources", Resource.class); desc.putListPropertyType("filters", String.class); desc.putListPropertyType("plugins", Plugin.class); addTypeDescription(desc); desc = new TypeDescription(BuildBase.class);
public BaseConstructor() { constructedObjects = new HashMap<Node, Object>(); recursiveObjects = new HashSet<Node>(); maps2fill = new ArrayList<RecursiveTuple<Map<Object, Object>, RecursiveTuple<Object, Object>>>(); sets2fill = new ArrayList<RecursiveTuple<Set<Object>, Object>>(); typeDefinitions = new HashMap<Class<? extends Object>, TypeDescription>(); typeTags = new HashMap<Tag, Class<? extends Object>>(); rootTag = null; explicitPropertyUtils = false; typeDefinitions.put(SortedMap.class, new TypeDescription(SortedMap.class, Tag.OMAP, TreeMap.class)); typeDefinitions.put(SortedSet.class, new TypeDescription(SortedSet.class, Tag.SET, TreeSet.class)); }
CustomConstructor(Class<?> theRoot) { super(theRoot); TypeDescription seedDesc = new TypeDescription(ParameterizedClass.class); seedDesc.putMapPropertyType("parameters", String.class, String.class); addTypeDescription(seedDesc); }
public UaaConfigConstructor() { super(UaaConfiguration.class); TypeDescription oauthDesc = new TypeDescription(OAuth.class); oauthDesc.putMapPropertyType("clients", String.class, OAuthClient.class); addTypeDescription(oauthDesc); TypeDescription clientDesc = new TypeDescription(Client.class); clientDesc.putListPropertyType(ClientConstants.AUTO_APPROVE, String.class); addTypeDescription(clientDesc); TypeDescription oauthClientDesc = new TypeDescription(OAuthClient.class); oauthClientDesc.putListPropertyType(ClientConstants.AUTO_APPROVE, String.class); addTypeDescription(oauthClientDesc); TypeDescription claimsDesc = new TypeDescription(Claims.class); claimsDesc.putListPropertyType("exclusions", String.class); addTypeDescription(clientDesc); TypeDescription policyDesc = new TypeDescription(Policy.class); policyDesc.putMapPropertyType("keys", String.class, KeySpec.class); addTypeDescription(policyDesc);
public static XmlSuite parse(String filePath, InputStream is) throws FileNotFoundException { Constructor constructor = new TestNGConstructor(XmlSuite.class); TypeDescription suiteDescription = new TypeDescription(XmlSuite.class); suiteDescription.addPropertyParameters("packages", XmlPackage.class); suiteDescription.addPropertyParameters("listeners", String.class); suiteDescription.addPropertyParameters("tests", XmlTest.class); suiteDescription.addPropertyParameters("method-selectors", XmlMethodSelector.class); constructor.addTypeDescription(suiteDescription); TypeDescription testDescription = new TypeDescription(XmlTest.class); testDescription.addPropertyParameters("classes", XmlClass.class); testDescription.addPropertyParameters("metaGroups", String.class, List.class); testDescription.addPropertyParameters("method-selectors", XmlMethodSelector.class); constructor.addTypeDescription(testDescription);
/** * Create Constructor for the specified class as the root. * * @param theRoot * - the class (usually JavaBean) to be constructed */ public Constructor(Class<? extends Object> theRoot) { this(new TypeDescription(checkRoot(theRoot))); }
protected Yaml getCustomYaml() { SnakeYamlCharmer charmer = new SnakeYamlCharmer(RawStmtsDoc.class); charmer.addHandler(StatementsOwner.class, "statements", new StatementsReader()); charmer.addHandler(StatementsOwner.class, "statement", new StatementsReader()); TypeDescription tds = new TypeDescription(RawStmtsDoc.class); tds.addPropertyParameters("blocks", RawStmtsBlock.class); charmer.addTypeDescription(tds); return new Yaml(charmer); }
/** * Specify that the property is a type-safe <code>List</code>. * * @param property * name of the JavaBean property * @param type * class of List values */ @Deprecated public void putListPropertyType(String property, Class<? extends Object> type) { addPropertyParameters(property, type); }
private Yaml getNewInstance(Class<?> clazz) { Constructor constructor = new Constructor(clazz); TypeDescription typeDescription = new TypeDescription(clazz); constructor.addTypeDescription(typeDescription); return new Yaml(constructor); } }
@Override public void register(YamlConstructorContext context) { context.getYamlConstructor().addTypeDescription(new TypeDescription(YamlVaultValue.class, YamlVaultValueRepresent.VAULT_TAG)); }
@Override public List<ServerBean> processServerConfiguration(FileReader fileReader) { List<ServerBean> servers = new ArrayList<ServerBean>(); Yaml yamlLoader = null; try { TypeDescription descr = new TypeDescription(ServerBeanList.class); descr.putListPropertyType(ConfigConstants.SERVERS_PROPERTY, ServerBean.class); yamlLoader = new Yaml(new Constructor(descr)); ServerBeanList serverList = yamlLoader.loadAs(fileReader, ServerBeanList.class); servers = serverList.getServers(); } catch (Exception e) { log.error("Configuration pasing error", e); throw new IllegalArgumentException( "Failed to parse configuration file: " + e.getMessage()); } return servers; }
public KubeClientConfigConstructor(PropertyUtils propertyUtils) { super(KubeClientConfig.class); TypeDescription configTypeDesc = new TypeDescription(KubeClientConfig.class); configTypeDesc.putListPropertyType(CONTEXTS, Context.class); configTypeDesc.putListPropertyType(CLUSTERS, Cluster.class); configTypeDesc.putListPropertyType(USERS, User.class); addTypeDescription(configTypeDesc); setPropertyUtils(propertyUtils); }
public BaseConstructor() { constructedObjects = new HashMap<Node, Object>(); recursiveObjects = new HashSet<Node>(); maps2fill = new ArrayList<RecursiveTuple<Map<Object, Object>, RecursiveTuple<Object, Object>>>(); sets2fill = new ArrayList<RecursiveTuple<Set<Object>, Object>>(); typeDefinitions = new HashMap<Class<? extends Object>, TypeDescription>(); typeTags = new HashMap<Tag, Class<? extends Object>>(); rootTag = null; explicitPropertyUtils = false; typeDefinitions.put(SortedMap.class, new TypeDescription(SortedMap.class, Tag.OMAP, TreeMap.class)); typeDefinitions.put(SortedSet.class, new TypeDescription(SortedSet.class, Tag.SET, TreeSet.class)); }
CustomConstructor(Class<?> theRoot) { super(theRoot); TypeDescription seedDesc = new TypeDescription(ParameterizedClass.class); seedDesc.putMapPropertyType("parameters", String.class, String.class); addTypeDescription(seedDesc); }