List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:com.whizzosoftware.hobson.dto.data.DataStreamDTOTest.java
private DataStreamDTO createDTO(DTOBuildContext ctx, boolean showDetails) { Collection<DataStreamField> vars = new ArrayList<>(); vars.add(new DataStreamField("field1", "test", VariableContext.create(DeviceContext.createLocal("plugin1", "device1"), "var1"))); HashSet<String> tags = new HashSet<>(); tags.add("tag1"); tags.add("tag2"); DataStream ds = new DataStream("ds1", "My DS", vars, tags); DataStreamDTO dto = new DataStreamDTO.Builder(ctx, ds, showDetails).build(); assertEquals("dataStreams:ds1", dto.getId()); if (showDetails) { assertEquals("My DS", dto.getName()); } else {//from w w w. ja v a2 s .c o m assertNull(dto.getName()); } return dto; }
From source file:de.dfki.resc28.ole.resources.Repository.java
@Override public Set<String> getAllowedMethods() { HashSet<String> allowedMethods = new HashSet<String>(); allowedMethods.add(HttpMethod.GET); allowedMethods.add(HttpMethod.HEAD); allowedMethods.add(HttpMethod.OPTIONS); allowedMethods.add(HttpMethod.POST); return allowedMethods; }
From source file:com.att.ajsc.csilogging.util.UtilLib.java
public static String getInput(String pathinfoArr[], int arrLength, String componentType, String pathInfo) { Set<String> endpointSet = null; /*// w w w.jav a 2 s . c o m * if (componentType.equalsIgnoreCase("rest")) { endpointSet = * DME2Helper.restletEndpointSet; } else { endpointSet = * DME2Helper.serviceEndpointSet; } */ HashSet<String> setBasedArrLenth = new HashSet<String>(); HashMap setBasedCharMap = new HashMap(); HashSet<String> setBasedValues = new HashSet<String>(); AntPathMatcher pathMatcher = new AntPathMatcher(); String inputBasedonLength[]; int globalvalue = 0; for (String s : endpointSet) { int dif = StringUtils.getLevenshteinDistance(pathInfo, s); if (globalvalue == 0 || globalvalue > dif) { globalvalue = dif; setBasedCharMap.put(globalvalue, s); } inputBasedonLength = s.split("\\/"); int i = inputBasedonLength.length; if (arrLength == i) { setBasedArrLenth.add(s); } } String inputBasedOnValues[]; for (String s1 : setBasedArrLenth) { inputBasedOnValues = s1.split("\\/"); int j = 1; while (compareValues(pathinfoArr[j], inputBasedOnValues[j])) { j++; if (j >= arrLength) { break; } } if (j == arrLength) { setBasedValues.add(s1); } } String input = ""; if (setBasedValues.size() == 1) { for (String s2 : setBasedValues) { input = s2; } } else { for (String s2 : setBasedValues) { if (pathMatcher.match(pathInfo, s2)) { input = s2; } } } if (input.isEmpty()) { input = (String) setBasedCharMap.get(globalvalue); } return "/" + componentType + input; }
From source file:org.geowebcache.layer.MetaTile.java
@SuppressWarnings("rawtypes") protected static void disposePlanarImageChain(PlanarImage pi, HashSet<PlanarImage> visited) { Vector sinks = pi.getSinks(); // check all the sinks (the image might be in the middle of a chain) if (sinks != null) { for (Object sink : sinks) { if (sink instanceof PlanarImage && !visited.contains(sink)) { disposePlanarImageChain((PlanarImage) sink, visited); } else if (sink instanceof BufferedImage) { ((BufferedImage) sink).flush(); }/*from w w w .j av a2 s. c o m*/ } } // dispose the image itself pi.dispose(); visited.add(pi); // check the image sources Vector sources = pi.getSources(); if (sources != null) { for (Object child : sources) { if (child instanceof PlanarImage && !visited.contains(child)) { disposePlanarImageChain((PlanarImage) child, visited); } else if (child instanceof BufferedImage) { ((BufferedImage) child).flush(); } } } // ImageRead might also hold onto a image input stream that we have to close if (pi instanceof RenderedOp) { RenderedOp op = (RenderedOp) pi; for (Object param : op.getParameterBlock().getParameters()) { if (param instanceof ImageInputStream) { ImageInputStream iis = (ImageInputStream) param; try { iis.close(); } catch (IOException e) { // fine, we tried } } } } }
From source file:edu.mayo.cts2.framework.plugin.service.bprdf.profile.AbstractQueryService.java
@Override public Set<? extends MatchAlgorithmReference> getSupportedMatchAlgorithms() { HashSet<MatchAlgorithmReference> returnSet = new HashSet<MatchAlgorithmReference>(); returnSet.add(StandardMatchAlgorithmReference.CONTAINS.getMatchAlgorithmReference()); return returnSet; }
From source file:jef.tools.ArrayUtils.java
/** * ?/*from w w w . j a va 2s.co m*/ * * @param ls * @param ls2 * @return */ public static Object[] union(Object[] ls, Object[] ls2) { HashSet<Object> set = new HashSet<Object>(Arrays.asList(ls)); for (Object o : ls2) { set.add(o); } return set.toArray(); }
From source file:com.boundary.plugin.sdk.jmx.MBeansTransformer.java
/** * Iterates over the attributes of an MBean * @param name {@link ObjectName}/*ww w . j a va 2 s . co m*/ */ private void traverseAttributes(ObjectName name) { MBeanServerConnection connection = this.client.getMBeanServerConnection(); MBeanInfo info; HashSet<String> checkTypes = new HashSet<String>(); checkTypes.add("long"); checkTypes.add("int"); checkTypes.add("javax.management.openmbean.CompositeData"); checkTypes.add("[Ljavax.management.openmbean.CompositeData;"); try { info = connection.getMBeanInfo(name); MBeanAttributeInfo[] attributes = info.getAttributes(); for (MBeanAttributeInfo attrInfo : attributes) { if (checkTypes.contains(attrInfo.getType())) { transform.beginAttribute(name, attrInfo); transform.endAttribute(); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.vmware.bdd.service.resmgmt.sync.filter.HostFilterByDsNameRegx.java
public HostFilterByDsNameRegx(String[] vcDsNameRegxs) { AuAssert.check(ArrayUtils.isNotEmpty(vcDsNameRegxs), "can't build an empty name regx filter."); HashSet<String> nameRegSet = new HashSet<>(); for (String name : vcDsNameRegxs) { nameRegSet.add(name); }/*from w w w . j a v a2s . c o m*/ for (String nameReg : nameRegSet) { Pattern pattern = Pattern.compile(nameReg); dsNameRegxSet.add(pattern); } }
From source file:ProductosEnVentaFacadeTest.java
@Test public void almacenarProductosEnVentaTest() { //Almacenar un campesino con su ubicacion Ubicacion u1 = new Ubicacion("Calle 160 # 36 - 45", "Chia", "Cundinamarca", "50", "50"); Campesino c1 = new Campesino(123456789, u1, "Pedro Nel", "Sanchez Carrasquilla", "4559875"); cf.guardarCampesino(c1);/*w ww . j a v a 2 s . c om*/ //Almacenar un producto que sera la categoria de los productos en venta a agregar Producto p1 = new Producto("Arroz Integral", 36, true); try { pf.saveProducto(p1); } catch (OperationFailedException ex) { Logger.getLogger(ProductosEnVentaFacadeTest.class.getName()).log(Level.SEVERE, null, ex); fail("No se esperaba una exception"); } //Agregar los productos en venta ProductoEnVenta pev1 = new ProductoEnVenta(c1, p1, "Arroz de una alta calidad", new Date(2015 - 1900, 6, 15), (float) (35.8), 3500); ProductoEnVenta pev2 = new ProductoEnVenta(c1, p1, "Arroz de una calidad baja", new Date(2015 - 1900, 6, 15), (float) (35.8), 2000); pvf.saveProductoEnVentaParaCampesino(c1, pev1); pvf.saveProductoEnVentaParaCampesino(c1, pev2); //Corroborar que se almacenaron los productos en venta List<ProductoEnVenta> prodVenta = pvf.getProductosEnVentaPorCampesino(c1.getIdCampesinos()); HashSet<ProductoEnVenta> conjProdVenta = new HashSet<>(); conjProdVenta.add(pev1); conjProdVenta.add(pev2); /* assertTrue("Se esperaba una lista de productos en venta de tamao diferente ", conjProdVenta.size()==prodVenta.size()); //Corroborar el contenido persistente de los productos en venta obtenido for(ProductoEnVenta pv1:conjProdVenta){ boolean exist = false; for(int i=0;i<prodVenta.size() && !exist;i++){ ProductoEnVenta pv2 = prodVenta.get(i); exist = pv1.getProductos().getIdProductos()==pv2.getProductos().getIdProductos() && pv1.getCampesinos().getIdCampesinos()==pv2.getCampesinos().getIdCampesinos() && pv1.getIdProductosEnVenta()==pv2.getIdProductosEnVenta() && pv1.getPrecioPorKg()==pv2.getPrecioPorKg() && pv1.getCantidadDisponible()==pv2.getCantidadDisponible(); } assertTrue("No se encontro un producto en venta esperado", exist); } */ }
From source file:com.clustercontrol.jobmanagement.util.MonitorJobWorker.java
/** * /*w w w. j a v a 2s .c o m*/ * @param sessionId ID */ public static void removeInfoBySessionId(String sessionId) { if (sessionId == null || sessionId.isEmpty()) { return; } /** */ List<RunInstructionInfo> runInstructionInfoList = RunHistoryUtil.findRunHistoryBySessionId(sessionId); for (RunInstructionInfo runInstructionInfo : runInstructionInfoList) { try { deleteSchedule(runInstructionInfo); } catch (HinemosUnknown e) { // ???? m_log.debug("schedule is not found."); } } /** */ HashSet<String> keySet = new HashSet<>(); for (Map.Entry<String, ConcurrentHashMap<RunInstructionInfo, MonitorInfo>> entry : monitorJobMap .entrySet()) { for (Map.Entry<RunInstructionInfo, MonitorInfo> childEntry : entry.getValue().entrySet()) { if (sessionId.equals(childEntry.getKey().getSessionId())) { monitorJobMap.get(childEntry.getValue().getMonitorTypeId()).remove(childEntry.getKey()); keySet.add(childEntry.getValue().getMonitorTypeId()); } } } // ?HinemosAgent?? if (keySet.contains(HinemosModuleConstant.MONITOR_LOGFILE)) { // SettingUpdateInfo.getInstance().setLogFileMonitorUpdateTime(HinemosTime.currentTimeMillis()); LogfileManagerUtil.broadcastConfigured(); } else if (keySet.contains(HinemosModuleConstant.MONITOR_WINEVENT)) { // Windows SettingUpdateInfo.getInstance().setWinEventMonitorUpdateTime(HinemosTime.currentTimeMillis()); WinEventManagerUtil.broadcastConfigured(); } else if (keySet.contains(HinemosModuleConstant.MONITOR_CUSTOM_N) || keySet.contains(HinemosModuleConstant.MONITOR_CUSTOM_S)) { // ?HinemosAgent?? SettingUpdateInfo.getInstance().setCustomMonitorUpdateTime(HinemosTime.currentTimeMillis()); CustomManagerUtil.broadcastConfigured(); } /** ? */ for (Map.Entry<RunInstructionInfo, Object> entry : prevMonitorValueMap.entrySet()) { if (sessionId.equals(entry.getKey().getSessionId())) { prevMonitorValueMap.remove(entry.getKey()); } } /** RunHistory */ for (RunInstructionInfo runInstructionInfo : runInstructionInfoList) { RunHistoryUtil.delRunHistory(runInstructionInfo); } }