/** * Constructs a new MultiKeyMap that decorates a <code>HashedMap</code>. */ public MultiKeyMap() { this(new HashedMap<MultiKey<? extends K>, V>()); }
/** * Read the map in using a custom routine. * * @param in the input stream * @throws IOException if an error occurs while reading from the stream * @throws ClassNotFoundException if an object read from the stream can not be loaded */ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); doReadObject(in); }
/** * Write the map out using a custom routine. * * @param out the output stream * @throws IOException if an error occurs while writing to the stream */ private void writeObject(final ObjectOutputStream out) throws IOException { out.defaultWriteObject(); doWriteObject(out); }
/** * Create an instance of the map used for storage when in delegation mode. * <p> * This can be overridden by subclasses to provide a different map implementation. * Not every AbstractHashedMap is suitable, identity and reference based maps * would be poor choices. * * @return a new AbstractHashedMap or subclass * @since 3.1 */ protected AbstractHashedMap<K, V> createDelegateMap() { return new HashedMap<>(); }
@TearDown(Level.Iteration) public void tearDown() { map = new HashMap<>(size); iterableMap = new HashedMap<>(size); mutableMap = UnifiedMap.newMap(size); for (int i = 0; i < size; i++) { map.put(i, i); mutableMap.put(i, i); iterableMap.put(i, i); } }
@SuppressWarnings("unchecked") public void testCountMatches() throws Exception { Assert.assertEquals(0, (int) run("COUNT_MATCHES(null, '*')", new HashedMap())); Assert.assertEquals(2, (int) run("COUNT_MATCHES('apachemetron', 'e')", new HashedMap())); Assert.assertEquals(2, (int) run("COUNT_MATCHES('anand', 'an')", new HashedMap())); Assert.assertEquals(0, (int) run("COUNT_MATCHES('abcd', null)", new HashedMap()));
@SuppressWarnings("unchecked") public void testChomp() throws Exception { Assert.assertEquals("abc", run("CHOMP('abc')", new HashedMap())); Assert.assertEquals("abc", run("CHOMP(msg)", ImmutableMap.of("msg", "abc\r\n"))); Assert.assertEquals("", run("CHOMP(msg)", ImmutableMap.of("msg", "\n"))); Assert.assertEquals("", run("CHOMP('')", new HashedMap())); Assert.assertEquals(null, run("CHOMP(null)", new HashedMap())); run("CHOMP(msg)", new HashedMap()); } catch (ParseException pe) { thrown = true;
@SuppressWarnings("unchecked") public void testChop() throws Exception { Assert.assertEquals("ab", run("CHOP('abc')", new HashedMap())); Assert.assertEquals(null, run("CHOP(null)", new HashedMap())); Assert.assertEquals("abc", run("CHOP(msg)", ImmutableMap.of("msg", "abc\r\n"))); Assert.assertEquals("", run("CHOP(msg)", ImmutableMap.of("msg", ""))); Assert.assertEquals("", run("CHOP(msg)", ImmutableMap.of("msg", "\n"))); Assert.assertEquals("", run("CHOP('')", new HashedMap())); run("CHOMP(msg)", new HashedMap()); } catch (ParseException pe) { thrown = true;
@SuppressWarnings("unchecked") public void testPrependIfMissing() throws Exception { Assert.assertEquals("xyzabc", run("PREPEND_IF_MISSING('abc', 'xyz')", new HashedMap())); Assert.assertEquals("xyzXYZabc", run("PREPEND_IF_MISSING('XYZabc', 'xyz', 'mno')", new HashedMap())); Assert.assertEquals("mnoXYZabc", run("PREPEND_IF_MISSING('mnoXYZabc', 'xyz', 'mno')", new HashedMap())); Assert.assertEquals(null, run("PREPEND_IF_MISSING(null, null, null)", new HashedMap())); Assert.assertEquals("xyz", run("PREPEND_IF_MISSING('', 'xyz', null)", new HashedMap()));
@SuppressWarnings("unchecked") public void testAppendIfMissing() throws Exception { Assert.assertEquals("apachemetron", run("APPEND_IF_MISSING('apache', 'metron')", new HashedMap())); Assert.assertEquals("abcXYZxyz", run("APPEND_IF_MISSING('abcXYZ', 'xyz', 'mno')", new HashedMap())); Assert.assertEquals(null, run("APPEND_IF_MISSING(null, null, null)", new HashedMap())); Assert.assertEquals("xyz", run("APPEND_IF_MISSING('', 'xyz', null)", new HashedMap()));
public BrickConfiguration(String name, BrickType type, String version, Set<PortDefinition> portDefinitions) { this(name, type, version, portDefinitions, new HashSet<>(), new HashedMap<>()); }
public EventLoggingListener( @Autowired EventRepository aRepo, @Lazy @Autowired(required = false) List<EventLoggingAdapter<?>> aAdapters) { repo = aRepo; adapterProxy = aAdapters; adapterCache = new HashedMap<>(); }
public EventLoggingListener( @Autowired EventRepository aRepo, @Lazy @Autowired(required = false) List<EventLoggingAdapter<?>> aAdapters) { repo = aRepo; adapterProxy = aAdapters; adapterCache = new HashedMap<>(); }
Object left = run("FILL_LEFT('123','X', 10)", new HashedMap()); Assert.assertNotNull(left); Assert.assertEquals(10, ((String) left).length()); Object right = run("FILL_RIGHT('123','X', 10)", new HashedMap()); Assert.assertNotNull(right); Assert.assertEquals(10, ((String) right).length()); Object same = run("FILL_RIGHT('123','X', 3)", new HashedMap()); Assert.assertEquals(3, ((String) same).length()); Assert.assertEquals("123", (String) same); Object tooBig = run("FILL_RIGHT('1234567890','X', 3)", new HashedMap()); Assert.assertEquals(10, ((String) tooBig).length()); Assert.assertEquals("1234567890", (String) tooBig); run("FILL_RIGHT('123','X', 'z' )", new HashedMap()); } catch (ParseException pe) { thrown = true; Object returnValue = run("FILL_RIGHT('123','', 10 )", new HashedMap()); } catch (ParseException pe) { thrown = true;
public Vary(int col, int numCategories, List<Integer> supRows, int[][] discreteData) { this.col = col; this.numCategories = numCategories; for (int i = 0; i < numCategories; i++) { rows.add(new ArrayList<Integer>()); } for (int i = 0; i < numCategories; i++) { subVaries.add(new HashedMap<Integer, Vary>()); } for (int i : supRows) { int index = discreteData[col][i]; if (index != -99) { rows.get(index).add(i); } } }
private static Map<String, String> getLocalizedStrings(OrienteerWebApplication app, String key, List<String> tags) { Map<String, String> localized = new HashedMap<>(3); for (String tag : tags) { localized.put(tag, getString(app, key, Locale.forLanguageTag(tag))); } return localized; }
protected List<Map<String, Object>> getAdapterInfo() { if (backends.size() == 0) { throw new IllegalStateException( "No machine learning adapter set - Provide at least one machine learning configuration"); } List<Map<String, Object>> maps = new ArrayList<>(); for (int i = 0; i < backends.size(); i++) { TcDeepLearningAdapter a = backends.get(i); Object userCode = userCodePath.get(i); List<Object> o = new ArrayList<>(); o.add(a); o.add(userCode); Map<String, Object> m = new HashedMap<>(); m.put(DIM_CLASSIFICATION_ARGS, o); maps.add(m); } return maps; }