List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:com.fitbur.testify.fixture.SpringIntegrationConfig.java
@Bean public HashSet<String> setOfStrings() { HashSet set = new HashSet(1); set.add("set"); return set;//from ww w . ja v a 2 s. co m }
From source file:com.qwazr.utils.server.RestApplication.java
@Override public Set<Class<?>> getClasses() { HashSet<Class<?>> classes = new HashSet<Class<?>>(); classes.add(JacksonConfig.class); classes.add(JacksonJsonProvider.class); classes.add(Jackson2JsonpInterceptor.class); return classes; }
From source file:com.google.gwt.emultest.java.util.HashSetTest.java
public void testAddWatch() { HashSet<String> s = new HashSet<String>(); s.add("watch"); assertTrue(s.contains("watch")); }
From source file:com.oneis.javascript.Runtime.java
/** * Initialize the shared JavaScript environment. Loads libraries and removes * methods of escaping the sandbox./*from w w w . jav a 2 s. c o m*/ */ public static void initializeSharedEnvironment(String frameworkRoot) throws java.io.IOException { // Don't allow this to be called twice if (sharedScope != null) { return; } long startTime = System.currentTimeMillis(); final Context cx = Runtime.enterContext(); try { final ScriptableObject scope = cx.initStandardObjects(null, false /* don't seal the standard objects yet */); if (!scope.has("JSON", scope)) { throw new RuntimeException( "Expecting built-in JSON support in Rhino, check version is at least 1.7R3"); } if (standardTemplateLoader == null) { throw new RuntimeException("StandardTemplateLoader for Runtime hasn't been set."); } String standardTemplateJSON = standardTemplateLoader.standardTemplateJSON(); scope.put("$STANDARDTEMPLATES", scope, standardTemplateJSON); // Load the library code FileReader bootScriptsFile = new FileReader(frameworkRoot + "/lib/javascript/bootscripts.txt"); LineNumberReader bootScripts = new LineNumberReader(bootScriptsFile); String scriptFilename = null; while ((scriptFilename = bootScripts.readLine()) != null) { FileReader script = new FileReader(frameworkRoot + "/" + scriptFilename); cx.evaluateReader(scope, script, scriptFilename, 1, null /* no security domain */); script.close(); } bootScriptsFile.close(); // Load the list of allowed globals FileReader globalsWhitelistFile = new FileReader( frameworkRoot + "/lib/javascript/globalswhitelist.txt"); HashSet<String> globalsWhitelist = new HashSet<String>(); LineNumberReader whitelist = new LineNumberReader(globalsWhitelistFile); String globalName = null; while ((globalName = whitelist.readLine()) != null) { String g = globalName.trim(); if (g.length() > 0) { globalsWhitelist.add(g); } } globalsWhitelistFile.close(); // Remove all the globals which aren't allowed, using a whitelist for (Object propertyName : scope.getAllIds()) // the form which includes the DONTENUM hidden properties { if (propertyName instanceof String) // ConsString is checked { // Delete any property which isn't in the whitelist if (!(globalsWhitelist.contains(propertyName))) { scope.delete((String) propertyName); // ConsString is checked } } else { // Not expecting any other type of property name in the global namespace throw new RuntimeException( "Not expecting global JavaScript scope to contain a property which isn't a String"); } } // Run through the globals again, just to check nothing escaped for (Object propertyName : scope.getAllIds()) { if (!(globalsWhitelist.contains(propertyName))) { throw new RuntimeException("JavaScript global was not destroyed: " + propertyName.toString()); } } // Run through the whilelist, and make sure that everything in it exists for (String propertyName : globalsWhitelist) { if (!scope.has(propertyName, scope)) { // The whitelist should only contain non-host objects created by the JavaScript source files. throw new RuntimeException( "JavaScript global specified in whitelist does not exist: " + propertyName); } } // And make sure java has gone, to check yet again that everything expected has been removed if (scope.get("java", scope) != Scriptable.NOT_FOUND) { throw new RuntimeException("JavaScript global 'java' escaped destruction"); } // Seal the scope and everything within in, so nothing else can be added and nothing can be changed // Asking initStandardObjects() to seal the standard library doesn't actually work, as it will leave some bits // unsealed so that decodeURI.prototype.pants = 43; works, and can pass information between runtimes. // This recursive object sealer does actually work. It can't seal the main host object class, so that's // added to the scope next, with the (working) seal option set to true. HashSet<Object> sealedObjects = new HashSet<Object>(); recursiveSealObjects(scope, scope, sealedObjects, false /* don't seal the root object yet */); if (sealedObjects.size() == 0) { throw new RuntimeException("Didn't seal any JavaScript globals"); } // Add the host object classes. The sealed option works perfectly, so no need to use a special seal function. defineSealedHostClass(scope, KONEISHost.class); defineSealedHostClass(scope, KObjRef.class); defineSealedHostClass(scope, KScriptable.class); defineSealedHostClass(scope, KLabelList.class); defineSealedHostClass(scope, KLabelChanges.class); defineSealedHostClass(scope, KLabelStatements.class); defineSealedHostClass(scope, KDateTime.class); defineSealedHostClass(scope, KObject.class); defineSealedHostClass(scope, KText.class); defineSealedHostClass(scope, KQueryClause.class); defineSealedHostClass(scope, KQueryResults.class); defineSealedHostClass(scope, KPluginAppGlobalStore.class); defineSealedHostClass(scope, KPluginResponse.class); defineSealedHostClass(scope, KTemplatePartialAutoLoader.class); defineSealedHostClass(scope, KAuditEntry.class); defineSealedHostClass(scope, KAuditEntryQuery.class); defineSealedHostClass(scope, KUser.class); defineSealedHostClass(scope, KUserData.class); defineSealedHostClass(scope, KWorkUnit.class); defineSealedHostClass(scope, KWorkUnitQuery.class); defineSealedHostClass(scope, KEmailTemplate.class); defineSealedHostClass(scope, KBinaryData.class); defineSealedHostClass(scope, KUploadedFile.class); defineSealedHostClass(scope, KStoredFile.class); defineSealedHostClass(scope, KJob.class); defineSealedHostClass(scope, KSessionStore.class); defineSealedHostClass(scope, KSecurityRandom.class); defineSealedHostClass(scope, KSecurityBCrypt.class); defineSealedHostClass(scope, KSecurityDigest.class); defineSealedHostClass(scope, KSecurityHMAC.class); defineSealedHostClass(scope, JdNamespace.class); defineSealedHostClass(scope, JdTable.class); defineSealedHostClass(scope, JdSelectClause.class); defineSealedHostClass(scope, JdSelect.class, true /* map inheritance */); defineSealedHostClass(scope, KGenerateTable.class); defineSealedHostClass(scope, KGenerateXLS.class, true /* map inheritance */); defineSealedHostClass(scope, KRefKeyDictionary.class); defineSealedHostClass(scope, KRefKeyDictionaryHierarchical.class, true /* map inheritance */); defineSealedHostClass(scope, KCheckingLookupObject.class); defineSealedHostClass(scope, KCollaborationService.class); defineSealedHostClass(scope, KCollaborationFolder.class); defineSealedHostClass(scope, KCollaborationItemList.class); defineSealedHostClass(scope, KCollaborationItem.class); defineSealedHostClass(scope, KAuthenticationService.class); // Seal the root now everything has been added scope.sealObject(); // Check JavaScript TimeZone checkJavaScriptTimeZoneIsGMT(); sharedScope = scope; } finally { cx.exit(); } initializeSharedEnvironmentTimeTaken = System.currentTimeMillis() - startTime; }
From source file:javadepchecker.Main.java
/** * Core method, this one fires off all others and is the one called from * Main. Check this package for unneeded dependencies and orphaned class * files// w w w.j a v a 2 s . c o m * * @param env * @return */ private static boolean checkPkg(File env) { boolean needed = true; boolean found = true; HashSet<String> pkgs = new HashSet<>(); Collection<String> deps = null; InputStream is = null; try { // load package.env Properties props = new Properties(); is = new FileInputStream(env); props.load(is); // load package deps, add to hashset if exist String depend = props.getProperty("DEPEND"); if (depend != null && !depend.isEmpty()) { for (String atom : depend.replaceAll("\"", "").split(":")) { String pkg = atom; if (atom.contains("@")) { pkg = atom.split("@")[1]; } pkgs.add(pkg); } } // load package classpath String classpath = props.getProperty("CLASSPATH"); if (classpath != null && !classpath.isEmpty()) { Main classParser = new Main(); for (String jar : classpath.replaceAll("\"", "").split(":")) { if (jar.endsWith(".jar")) { classParser.processJar(new JarFile(image + jar)); } } deps = classParser.getDeps(); } for (String pkg : pkgs) { if (!depNeeded(pkg, deps)) { if (needed) { System.out.println("Possibly unneeded dependencies found"); } System.out.println("\t" + pkg); needed = false; } } found = depsFound(pkgs, deps); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (is != null) is.close(); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } return needed && found; }
From source file:com.china317.gmmp.gmmp_report_analysis.App.java
private static void analysisBanche(String yyyyMMdd, ApplicationContext context) { try {/*from w ww .ja va 2s . com*/ String businessType = "2"; // System.out.println("[classpath]"+System.getProperty("java.class.path"));//classpaht // System.out.println("[path]"+System.getProperty("user.dir"));//? log.info("[get baseVehicle begin---------]"); VehicleDao vehicleDao = (VehicleDao) context.getBean("vehicleDao"); List<Vehicle> vehs = vehicleDao.getBaseVehicleByDate(yyyyMMdd, businessType); List<List<Vehicle>> list_tm = ListUtil.splitList(vehs, 400); log.info("[get baseVehicle end1---------],vehicle total:" + vehs.size()); log.info("[get baseVehicle end2---------],list_tm total:" + list_tm.size()); for (List<Vehicle> vls : list_tm) { Map<String, Vehicle> vehMap = new HashMap<String, Vehicle>(); log.info("[code set init------]"); HashSet<String> codes = new HashSet<String>(); for (Vehicle v : vls) { codes.add(v.getCode()); vehMap.put(v.getCode(), v); } log.info("[code set end------]" + "setSize:" + vehMap.size()); List<VehicleLocate> list = new ArrayList<VehicleLocate>(); if (codes.size() > 0) { VehicleLocateDao vehicleLocateDao_gmmpraw = (VehicleLocateDao) context .getBean("vehicleLocateDaoGmmpRaw"); list = vehicleLocateDao_gmmpraw.findHistoryByParams(yyyyMMdd, codes); log.info("[this time total Points Size]:" + list.size()); } Map<String, List<VehicleLocate>> map = new HashMap<String, List<VehicleLocate>>(); for (VehicleLocate entity : list) { if (entity.getGpsSpeed() < 160) { // businessType Vehicle tmpV = vehMap.get(entity.getCode()); entity.setBusinessType(tmpV.getBusinessType()); List<VehicleLocate> records = map.get(entity.getCode()); if (records == null) { records = new ArrayList<VehicleLocate>(); } long lastlong = DateTime.accountTime3(entity.getGpsTime(), entity.getGetTime()); if (lastlong <= 10 * 60) { records.add(entity); } map.put(entity.getCode(), records); } } log.info("analysis begin ,total:" + map.size()); Iterator<String> it = map.keySet().iterator(); while (it.hasNext()) { String key = it.next(); List<VehicleLocate> tmps = map.get(key); log.info("analysis vehicle code:" + key + "sort list begin, list size:" + tmps.size()); Collections.sort(tmps, new Comparator<VehicleLocate>() { public int compare(VehicleLocate o1, VehicleLocate o2) { Date d1 = o1.getGpsTime(); Date d2 = o2.getGpsTime(); if (d1.after(d2)) { return 1; } else if (d1.before(d2)) { return -1; } else { return 0; } } }); log.info("analysis vehicle code:" + key + "sort list end"); log.info("analysis vehicle code:" + key + "OVERSPEED OFFLINE ANALYSIS begin"); for (int i = 0; i < tmps.size(); i++) { VehicleLocate e = tmps.get(i); AreaAddProcessor.addAreaRuleInfo(e); /* * log.info("[vehcilelocate properties]" + e.getCode() + * "; gpstime:" + e.getGpsTime() + "; gpsSpeed:" + * e.getGpsSpeed() + "; businessType:" + * e.getBusinessType() + "; lon:" + e.getLon() + * "; lat:" + e.getLat() + "; acc:" + e.getACCState()); */ PtmAnalysisImp.getInstance().overSpeedAnalysis(e); // PtmAnalysisImp.getInstance().offlineAnalysis(e, // yyyyMMdd); // ? PtmAnalysisImp.getInstance().putLastRecord(e); } log.info("analysis vehicle code:" + key + "OVERSPEED OFFLINE ANALYSIS end"); log.info("result: overspeed:" + PtmAnalysisImp.getInstance().getOverSpeedRecordsSize() + "; offline:" + PtmAnalysisImp.getInstance().getOfflineRecordsSize()); // PtmAnalysisImp.getInstance().clear(); } // OverSpeedRecordsStoreIntoDB(PtmAnalysisImp.getInstance() // .getOverSpeedRecords(), context); PtmOverSpeedRecordsStoreIntoDB(PtmAnalysisImp.getInstance().getOverSpeedRecords(), context); } log.info("analysis end"); log.info("[Ptm ended]"); } catch (Exception e) { log.error(e); } }
From source file:com.china317.gmmp.gmmp_report_analysis.App.java
private static void analysisBaoChe(String yyyyMMdd, ApplicationContext context) throws Exception { try {/* www .j a v a 2 s . co m*/ log.info("[Baoche App started]"); String businessType = "3"; // System.out.println("[classpath]"+System.getProperty("java.class.path"));//classpaht // System.out.println("[path]"+System.getProperty("user.dir"));//? log.info("[Baoche get baseVehicle begin---------]"); VehicleDao vehicleDao = (VehicleDao) context.getBean("vehicleDao"); List<Vehicle> vehs = vehicleDao.getBaseVehicleByDate(yyyyMMdd, businessType); List<List<Vehicle>> list_tm = ListUtil.splitList(vehs, 400); log.info("[Baoche get baseVehicle end1---------],vehicle total:" + vehs.size()); log.info("[Baoche get baseVehicle end2---------],list_tm total:" + list_tm.size()); for (List<Vehicle> vls : list_tm) { Map<String, Vehicle> vehMap = new HashMap<String, Vehicle>(); log.info("[Baoche code set init------]"); HashSet<String> codes = new HashSet<String>(); for (Vehicle v : vls) { codes.add(v.getCode()); vehMap.put(v.getCode(), v); } log.info("[Baoche code set end------]" + "setSize:" + vehMap.size()); List<VehicleLocate> list = new ArrayList<VehicleLocate>(); if (codes.size() > 0) { VehicleLocateDao vehicleLocateDao_gmmpraw = (VehicleLocateDao) context .getBean("vehicleLocateDaoGmmpRaw"); list = vehicleLocateDao_gmmpraw.findHistoryByParams(yyyyMMdd, codes); log.info("[Baoche this time total Points Size]:" + list.size()); } Map<String, List<VehicleLocate>> map = new HashMap<String, List<VehicleLocate>>(); for (VehicleLocate entity : list) { if (entity.getGpsSpeed() < 160) { // businessType Vehicle tmpV = vehMap.get(entity.getCode()); entity.setBusinessType(tmpV.getBusinessType()); List<VehicleLocate> records = map.get(entity.getCode()); if (records == null) { records = new ArrayList<VehicleLocate>(); } long lastlong = DateTime.accountTime3(entity.getGpsTime(), entity.getGetTime()); if (lastlong <= 10 * 60) { records.add(entity); } map.put(entity.getCode(), records); } } log.info("analysis begin ,total:" + map.size()); Iterator<String> it = map.keySet().iterator(); while (it.hasNext()) { String key = it.next(); List<VehicleLocate> tmps = map.get(key); log.info("analysis vehicle code:" + key + "sort list begin, list size:" + tmps.size()); Collections.sort(tmps, new Comparator<VehicleLocate>() { public int compare(VehicleLocate o1, VehicleLocate o2) { Date d1 = o1.getGpsTime(); Date d2 = o2.getGpsTime(); if (d1.after(d2)) { return 1; } else if (d1.before(d2)) { return -1; } else { return 0; } } }); log.info("analysis vehicle code:" + key + "sort list end"); log.info("analysis vehicle code:" + key + "OVERSPEED OFFLINE ANALYSIS begin"); for (int i = 0; i < tmps.size(); i++) { VehicleLocate e = tmps.get(i); AreaAddProcessor.addAreaRuleInfo(e); /* * log.info("[Baoche vehcilelocate properties]" + * e.getCode() + "; gpstime:" + e.getGpsTime() + * "; gpsSpeed:" + e.getGpsSpeed() + "; businessType:" + * e.getBusinessType() + "; lon:" + e.getLon() + * "; lat:" + e.getLat() + "; acc:" + e.getACCState()); */ BaocheAnalysisImp.getInstance().overSpeedAnalysis(e); // BaocheAnalysisImp.getInstance().offlineAnalysis(e, // yyyyMMdd); // ?? BaocheAnalysisImp.getInstance().xlpAlarmAnalysis(e); // ? BaocheAnalysisImp.getInstance().putLastRecord(e); } // BaocheAnalysisImp.getInstance().clear(); log.info("analysis vehicle code:" + key + "OVERSPEED OFFLINE ANALYSIS end"); log.info("result: overspeed:" + BaocheAnalysisImp.getInstance().getOverSpeedRecordsSize() + "; offline:" + BaocheAnalysisImp.getInstance().getOfflineRecordsSize()); } LybcOverSpeedRecordsStoreIntoDB(BaocheAnalysisImp.getInstance().getOverSpeedRecords(), context); // IntOutNoneRecordsStoreIntoDB(BaocheAnalysisImp.getInstance().getIniOutNoneRecords(), context); // InOutMoreRecordsStoreIntoDB(BaocheAnalysisImp.getInstance().getIniOutMoreRecords(), context); } log.info("analysis end"); log.info("[Baoche ended]"); } catch (Exception e) { log.error(e); } }
From source file:com.china317.gmmp.gmmp_report_analysis.App.java
private static void analysisDgm(String yyyyMMdd, ApplicationContext context) { try {//from w ww. ja va 2s . c o m log.info("[Dgm App started]"); String businessType = "1"; DgmAnalysisImp.getInstance().clear(); // System.out.println("[classpath]"+System.getProperty("java.class.path"));//classpaht // System.out.println("[path]"+System.getProperty("user.dir"));//? log.info("[Dgm get baseVehicle begin---------]"); VehicleDao vehicleDao = (VehicleDao) context.getBean("vehicleDao"); List<Vehicle> vehs = vehicleDao.getBaseVehicleByDate(yyyyMMdd, businessType); List<List<Vehicle>> list_tm = ListUtil.splitList(vehs, 400); log.info("[Dgm get baseVehicle end1---------],vehicle total:" + vehs.size()); log.info("[Dgm get baseVehicle end2---------],list_tm total:" + list_tm.size()); for (List<Vehicle> vls : list_tm) { Map<String, Vehicle> vehMap = new HashMap<String, Vehicle>(); log.info("[Dgm code set init------]"); HashSet<String> codes = new HashSet<String>(); for (Vehicle v : vls) { codes.add(v.getCode()); vehMap.put(v.getCode(), v); } log.info("[Dgm code set end------]" + "setSize:" + vehMap.size()); List<VehicleLocate> list = new ArrayList<VehicleLocate>(); if (codes.size() > 0) { VehicleLocateDao vehicleLocateDao_gmmpraw = (VehicleLocateDao) context .getBean("vehicleLocateDaoGmmpRaw"); list = vehicleLocateDao_gmmpraw.findHistoryByParams(yyyyMMdd, codes); log.info("[Dgm this time total Points Size]:" + list.size()); } Map<String, List<VehicleLocate>> map = new HashMap<String, List<VehicleLocate>>(); for (VehicleLocate entity : list) { if (entity.getGpsSpeed() < 160) { // businessType Vehicle tmpV = vehMap.get(entity.getCode()); entity.setBusinessType(tmpV.getBusinessType()); List<VehicleLocate> records = map.get(entity.getCode()); if (records == null) { records = new ArrayList<VehicleLocate>(); } long lastlong = DateTime.accountTime3(entity.getGpsTime(), entity.getGetTime()); if (lastlong <= 10 * 60) { records.add(entity); } map.put(entity.getCode(), records); } } log.info("analysis begin ,total:" + map.size()); Iterator<String> it = map.keySet().iterator(); int index = 0; while (it.hasNext()) { index++; String key = it.next(); List<VehicleLocate> tmps = map.get(key); log.info("[Dgm]" + index + "analysis vehicle code:" + key + "sort list begin, list size:" + tmps.size()); Collections.sort(tmps, new Comparator<VehicleLocate>() { public int compare(VehicleLocate o1, VehicleLocate o2) { Date d1 = o1.getGpsTime(); Date d2 = o2.getGpsTime(); if (d1.after(d2)) { return 1; } else if (d1.before(d2)) { return -1; } else { return 0; } } }); log.info("analysis vehicle code:" + key + "sort list end"); DgmAnalysisImp.getInstance().fatigueAnalysis(tmps, yyyyMMdd); log.info("-------Fatigue Analysis end"); for (int i = 0; i < tmps.size(); i++) { VehicleLocate e = tmps.get(i); AreaAddProcessor.addAreaRuleInfo(e); /* * log.info("[Dgm vehcilelocate properties]" + * e.getCode() + "; gpstime:" + e.getGpsTime() + * "; gpsSpeed:" + e.getGpsSpeed() + "; businessType:" + * e.getBusinessType() + "; lon:" + e.getLon() + * "; lat:" + e.getLat() + "; acc:" + e.getACCState()); */ DgmAnalysisImp.getInstance().addZeroBegin(e); DgmAnalysisImp.getInstance().overSpeedAnalysis(e); DgmAnalysisImp.getInstance().offlineAnalysis(e, yyyyMMdd); DgmAnalysisImp.getInstance().fobiddenAnalysis(e, i, tmps.size(), yyyyMMdd); DgmAnalysisImp.getInstance().illegalParkingAnalysis(e); DgmAnalysisImp.getInstance().illegalInOutAnalysis(e); // ? DgmAnalysisImp.getInstance().putLastRecord(e); } log.info("analysis vehicle code:" + key + "OVERSPEED OFFLINE ANALYSIS end"); log.info("result: overspeed:" + DgmAnalysisImp.getInstance().getOverSpeedRecordsSize() + "; offline:" + DgmAnalysisImp.getInstance().getOfflineRecordsSize()); // DgmAnalysisImp.getInstance().clear(); } FatigueRecordsStoreIntoDB(DgmAnalysisImp.getInstance().getFatigueMap(), context); log.info("--------Fatigue store into DB end"); // OverSpeedRecordsStoreIntoDB(DgmAnalysisImp.getInstance() // .getOverSpeedMap(), context); DgmOverSpeedRecordsStoreIntoDB(DgmAnalysisImp.getInstance().getOverSpeedMap(), context); DgmEntryExitStoreIntoDB(DgmAnalysisImp.getInstance().getExitMap(), context); DgmFobbidenStoreIntoDB(DgmAnalysisImp.getInstance().getForbiddeningMap(), context); DgmIllegalParkingStoreIntoDB(DgmAnalysisImp.getInstance().getIllegalParking(), context); } log.info("analysis end"); log.info("[Dgm ended]"); } catch (Exception e) { log.error(e); } }
From source file:at.ac.univie.isc.asio.security.ExpandAuthoritiesContainerTest.java
@Theory public void maps_multiple_role_container_to_union(final Role one, final Role two) { final HashSet<GrantedAuthority> union = Sets.newHashSet(); union.add(one); union.addAll(one.getGrantedAuthorities()); union.add(two);/*from w w w .j a va 2 s .c o m*/ union.addAll(two.getGrantedAuthorities()); final Object[] expected = union.toArray(); final Collection<? extends GrantedAuthority> actual = subject.mapAuthorities(Arrays.asList(one, two)); assertThat(actual, containsInAnyOrder(expected)); }
From source file:de.cinovo.cloudconductor.api.model.ModelToJsonTest.java
/** * @throws JsonProcessingException on error *//*from w ww . jav a 2s . co m*/ @Test public void singleObjects() throws JsonProcessingException { SSHKey key = new SSHKey("akey", "aowner"); System.out.println(this.mapper.writeValueAsString(key)); Set<SSHKey> keys = new HashSet<>(); keys.add(key); System.out.println(this.mapper.writeValueAsString(keys)); System.out.println(this.mapper.writeValueAsString(keys.toArray(new SSHKey[0]))); HashSet<Dependency> hashSet = new HashSet<Dependency>(); hashSet.add(new Dependency("moep", "moep", "<", DependencyType.PROVIDES.toString())); PackageVersion v = new PackageVersion("test", "test", hashSet); System.out.println(this.mapper.writeValueAsString(v)); }