/** * Get JavaBean properties to be serialised. The order is respected. This * method may be overridden to provide custom property selection or order. * * @param type * - JavaBean to inspect the properties * @return properties to serialise */ protected Set<Property> getProperties(Class<? extends Object> type) { if (typeDefinitions.containsKey(type)) { return typeDefinitions.get(type).getProperties(); } return getPropertyUtils().getProperties(type); } }
public void setBeanAccess(BeanAccess beanAccess) { constructor.getPropertyUtils().setBeanAccess(beanAccess); representer.getPropertyUtils().setBeanAccess(beanAccess); }
public TypeDescription addTypeDescription(TypeDescription td) { if (Collections.EMPTY_MAP == typeDefinitions) { typeDefinitions = new HashMap<Class<? extends Object>, TypeDescription>(); } if (td.getTag() != null) { addClassTag(td.getType(), td.getTag()); } td.setPropertyUtils(getPropertyUtils()); return typeDefinitions.put(td.getType(), td); }
private static DumperOptions initDumperOptions(Representer representer) { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(representer.getDefaultFlowStyle()); dumperOptions.setDefaultScalarStyle(representer.getDefaultScalarStyle()); dumperOptions.setAllowReadOnlyProperties(representer.getPropertyUtils().isAllowReadOnlyProperties()); dumperOptions.setTimeZone(representer.getTimeZone()); return dumperOptions; }
LoaderOptions loadingConfig, Resolver resolver) { if (!constructor.isExplicitPropertyUtils()) { constructor.setPropertyUtils(representer.getPropertyUtils()); } else if (!representer.isExplicitPropertyUtils()) { representer.setPropertyUtils(constructor.getPropertyUtils()); representer.getPropertyUtils() .setAllowReadOnlyProperties(dumperOptions.isAllowReadOnlyProperties()); representer.setTimeZone(dumperOptions.getTimeZone());
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.representer.Representer; public class YamlReader { public static <T> T readYaml(InputStream is, Class<T> clazz){ Representer representer = new Representer(); // Set null for missing values in the yaml representer.getPropertyUtils().setSkipMissingProperties(true); Yaml yaml = new Yaml(representer); T data = yaml.loadAs(is, clazz); return data; } }
/** * Get JavaBean properties to be serialised. The order is respected. This * method may be overridden to provide custom property selection or order. * * @param type * - JavaBean to inspect the properties * @return properties to serialise */ protected Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException { return getPropertyUtils().getProperties(type); } }
/** * Get JavaBean properties to be serialised. The order is respected. This * method may be overridden to provide custom property selection or order. * * @param type * - JavaBean to inspect the properties * @return properties to serialise */ protected Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException { return getPropertyUtils().getProperties(type); } }
/** * Get JavaBean properties to be serialised. The order is respected. This * method may be overridden to provide custom property selection or order. * * @param type * - JavaBean to inspect the properties * @return properties to serialise */ protected Set<Property> getProperties(Class<? extends Object> type) { if (typeDefinitions.containsKey(type)) { return typeDefinitions.get(type).getProperties(); } return getPropertyUtils().getProperties(type); } }
public static MxisdConfig loadFromFile(String path) throws IOException { Representer rep = new Representer(); rep.getPropertyUtils().setAllowReadOnlyProperties(true); rep.getPropertyUtils().setSkipMissingProperties(true); Yaml yaml = new Yaml(new Constructor(MxisdConfig.class), rep); try (FileInputStream is = new FileInputStream(path)) { Object o = yaml.load(is); return GsonUtil.get().fromJson(GsonUtil.get().toJson(o), MxisdConfig.class); } }
public void setBeanAccess(BeanAccess beanAccess) { constructor.getPropertyUtils().setBeanAccess(beanAccess); representer.getPropertyUtils().setBeanAccess(beanAccess); }
public void setBeanAccess(BeanAccess beanAccess) { constructor.getPropertyUtils().setBeanAccess(beanAccess); representer.getPropertyUtils().setBeanAccess(beanAccess); }
public void setBeanAccess(BeanAccess beanAccess) { constructor.getPropertyUtils().setBeanAccess(beanAccess); representer.getPropertyUtils().setBeanAccess(beanAccess); }
public TypeDescription addTypeDescription(TypeDescription td) { if (Collections.EMPTY_MAP == typeDefinitions) { typeDefinitions = new HashMap<Class<? extends Object>, TypeDescription>(); } if (td.getTag() != null) { addClassTag(td.getType(), td.getTag()); } td.setPropertyUtils(getPropertyUtils()); return typeDefinitions.put(td.getType(), td); }
public IKubeClientConfig loadKubeClientConfig(Reader reader) { Representer representer = new Representer(); Yaml parser = new Yaml(new KubeClientConfigConstructor(new YamlPropertyUtils()), representer); representer.getPropertyUtils().setSkipMissingProperties(true); return parser.loadAs(reader, KubeClientConfig.class); }
public IKubeClientConfig loadKubeClientConfig(Reader reader) { Representer representer = new Representer(); Yaml parser = new Yaml(new KubeClientConfigConstructor(new YamlPropertyUtils()), representer); representer.getPropertyUtils().setSkipMissingProperties(true); return parser.loadAs(reader, KubeClientConfig.class); }
private PackageMetadata loadPackageMetadata(File file) { // The Representer will not try to set the value in the YAML on the // Java object if it isn't present on the object Representer representer = new Representer(); representer.getPropertyUtils().setSkipMissingProperties(true); Yaml yaml = new Yaml(new Constructor(PackageMetadata.class), representer); String fileContents = null; try { fileContents = FileUtils.readFileToString(file); } catch (IOException e) { throw new SkipperException("Error reading yaml file", e); } PackageMetadata pkgMetadata = (PackageMetadata) yaml.load(fileContents); return pkgMetadata; } }
public YamlReader(Constructor rootConstructor) { Representer representer = new Representer(); representer.getPropertyUtils().setSkipMissingProperties(true); yamlParser = new Yaml(rootConstructor, representer, new DumperOptions(), new CustomResolver()); }
private PackageMetadata loadPackageMetadata(File file) { // The Representer will not try to set the value in the YAML on the // Java object if it isn't present on the object Representer representer = new Representer(); representer.getPropertyUtils().setSkipMissingProperties(true); Yaml yaml = new Yaml(new Constructor(PackageMetadata.class), representer); String fileContents = null; try { fileContents = FileUtils.readFileToString(file); } catch (IOException e) { throw new SkipperException("Error reading yaml file", e); } PackageMetadata pkgMetadata = (PackageMetadata) yaml.load(fileContents); return pkgMetadata; } }
private static DumperOptions initDumperOptions(Representer representer) { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(representer.getDefaultFlowStyle()); dumperOptions.setDefaultScalarStyle(representer.getDefaultScalarStyle()); dumperOptions.setAllowReadOnlyProperties(representer.getPropertyUtils().isAllowReadOnlyProperties()); dumperOptions.setTimeZone(representer.getTimeZone()); return dumperOptions; }