target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testIsBlank() { Assert.assertTrue(StringUtils.isBlank(null)); Assert.assertTrue(StringUtils.isBlank("")); Assert.assertTrue(StringUtils.isBlank(" ")); Assert.assertFalse(StringUtils.isBlank("foobar")); Assert.assertFalse(StringUtils.isBlank("foo bar")); }
|
public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; }
|
StringUtils { public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; } }
|
StringUtils { public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; } }
|
StringUtils { public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; } static boolean isNoneBlank(final CharSequence... css); static boolean isEmpty(final Object[] array); static boolean isBlank(final CharSequence cs); }
|
StringUtils { public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; } static boolean isNoneBlank(final CharSequence... css); static boolean isEmpty(final Object[] array); static boolean isBlank(final CharSequence cs); }
|
@Test public void testEtcdLoad() { ConfigScan.scan(); ServerConfigLoader loader = new ServerConfigLoader(); EtcdConfigLoader etcdConfigLoader = new EtcdConfigLoader(client); loader.load(ConfigLoader.Context::new, (context, config) -> { if (config != null) { if (StringUtils.isNoneBlank(config.getConfigMode())) { String configMode = config.getConfigMode(); if (configMode.equals("etcd")) { etcdConfigLoader.load(context, this::assertTest); } } } }); }
|
private void etcdLoad(final Supplier<Context> context, final LoaderHandler<EtcdConfig> handler, final EtcdConfig config) { if (config != null) { check(config); LOGGER.info("loader etcd config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("etcd.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.etcd." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::etcdFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (Exception e) { LOGGER.error("passive etcd remote started error...."); } } else { throw new ConfigException("etcd config is null"); } }
|
EtcdConfigLoader implements ConfigLoader<EtcdConfig> { private void etcdLoad(final Supplier<Context> context, final LoaderHandler<EtcdConfig> handler, final EtcdConfig config) { if (config != null) { check(config); LOGGER.info("loader etcd config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("etcd.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.etcd." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::etcdFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (Exception e) { LOGGER.error("passive etcd remote started error...."); } } else { throw new ConfigException("etcd config is null"); } } }
|
EtcdConfigLoader implements ConfigLoader<EtcdConfig> { private void etcdLoad(final Supplier<Context> context, final LoaderHandler<EtcdConfig> handler, final EtcdConfig config) { if (config != null) { check(config); LOGGER.info("loader etcd config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("etcd.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.etcd." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::etcdFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (Exception e) { LOGGER.error("passive etcd remote started error...."); } } else { throw new ConfigException("etcd config is null"); } } EtcdConfigLoader(); EtcdConfigLoader(final EtcdClient client); }
|
EtcdConfigLoader implements ConfigLoader<EtcdConfig> { private void etcdLoad(final Supplier<Context> context, final LoaderHandler<EtcdConfig> handler, final EtcdConfig config) { if (config != null) { check(config); LOGGER.info("loader etcd config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("etcd.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.etcd." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::etcdFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (Exception e) { LOGGER.error("passive etcd remote started error...."); } } else { throw new ConfigException("etcd config is null"); } } EtcdConfigLoader(); EtcdConfigLoader(final EtcdClient client); @Override void load(final Supplier<Context> context, final LoaderHandler<EtcdConfig> handler); @Override void passive(final Supplier<Context> context, final PassiveHandler<Config> handler, final Config config); }
|
EtcdConfigLoader implements ConfigLoader<EtcdConfig> { private void etcdLoad(final Supplier<Context> context, final LoaderHandler<EtcdConfig> handler, final EtcdConfig config) { if (config != null) { check(config); LOGGER.info("loader etcd config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("etcd.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.etcd." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::etcdFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (Exception e) { LOGGER.error("passive etcd remote started error...."); } } else { throw new ConfigException("etcd config is null"); } } EtcdConfigLoader(); EtcdConfigLoader(final EtcdClient client); @Override void load(final Supplier<Context> context, final LoaderHandler<EtcdConfig> handler); @Override void passive(final Supplier<Context> context, final PassiveHandler<Config> handler, final Config config); }
|
@Test public void testJavaBeanBind() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.stringTest", "123"); map.put("hmily.integerTest", 456); map.put("hmily.doubleTest", 42.12); map.put("hmily.longTest", 100L); map.put("hmily.chartTest", 'a'); map.put("hmily.floatTest", 12.1F); map.put("hmily.boolTest", true); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>(propertySource, PropertyKeyParse.INSTANCE); Binder binder = Binder.of(configPropertySource); BindData<JavaBeanBinderTest> data = BindData.of(DataType.of(JavaBeanBinderTest.class), JavaBeanBinderTest::new); JavaBeanBinderTest bind = binder.bind("hmily", data); Assert.assertEquals(map.get("hmily.stringTest"), bind.getStringTest()); Assert.assertEquals(map.get("hmily.integerTest"), bind.getIntegerTest()); Assert.assertEquals(map.get("hmily.doubleTest"), bind.getDoubleTest()); Assert.assertEquals(map.get("hmily.chartTest"), bind.getChartTest()); Assert.assertEquals(map.get("hmily.longTest"), bind.getLongTest()); Assert.assertEquals(map.get("hmily.floatTest"), bind.getFloatTest()); Assert.assertEquals(map.get("hmily.boolTest"), bind.getBoolTest()); }
|
@Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; }
|
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; } }
|
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; } }
|
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; } @Override T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder); }
|
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; } @Override T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder); }
|
@Test public void testJavaBeanBindParse() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.stringTest", 123); map.put("hmily.integerTest", "123"); map.put("hmily.doubleTest", "123"); map.put("hmily.longTest", "123"); map.put("hmily.chartTest", "A"); map.put("hmily.floatTest", "123"); map.put("hmily.boolTest", "true"); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>(propertySource, PropertyKeyParse.INSTANCE); Binder binder = Binder.of(configPropertySource); BindData<JavaBeanBinderTest> data = BindData.of(DataType.of(JavaBeanBinderTest.class), JavaBeanBinderTest::new); JavaBeanBinderTest bind = binder.bind("hmily", data); Assert.assertEquals("123", bind.getStringTest()); Assert.assertEquals(Integer.valueOf(123), bind.getIntegerTest()); Assert.assertEquals(Double.valueOf(123), bind.getDoubleTest()); Assert.assertEquals(Character.valueOf('A'), bind.getChartTest()); Assert.assertEquals(Long.valueOf(123), bind.getLongTest()); Assert.assertEquals(Float.valueOf(123), bind.getFloatTest()); Assert.assertEquals(Boolean.TRUE, bind.getBoolTest()); }
|
@Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; }
|
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; } }
|
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; } }
|
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; } @Override T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder); }
|
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; } @Override T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder); }
|
@Test public void testMap() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.map.userName", "sixh"); map.put("hmily.map.passWord", 123456); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>(propertySource, PropertyKeyParse.INSTANCE); Binder binder = Binder.of(configPropertySource); BindData<MapPojo> data = BindData.of(DataType.of(MapPojo.class), MapPojo::new); MapPojo bind = binder.bind("hmily", data); Assert.assertEquals(bind.getMap().get("userName"), map.get("hmily.map.userName")); Assert.assertEquals(bind.getMap().get("passWord"), map.get("hmily.map.passWord")); System.out.println(bind); }
|
@Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; }
|
MapBinder extends AggregateBinder<Map<Object, Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; } }
|
MapBinder extends AggregateBinder<Map<Object, Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; } MapBinder(final Binder.Env env); }
|
MapBinder extends AggregateBinder<Map<Object, Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; } MapBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Map<Object, Object> object); @Override boolean isAllowRecursiveBinding(final Binder.Env source); }
|
MapBinder extends AggregateBinder<Map<Object, Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; } MapBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Map<Object, Object> object); @Override boolean isAllowRecursiveBinding(final Binder.Env source); }
|
@Test public void testMapGeneric() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.map2.userName", "456"); map.put("hmily.map2.passWord", 123456); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>(propertySource, PropertyKeyParse.INSTANCE); Binder binder = Binder.of(configPropertySource); BindData<MapPojo> data = BindData.of(DataType.of(MapPojo.class), MapPojo::new); MapPojo bind = binder.bind("hmily", data); Assert.assertEquals(bind.getMap2().get("userName"), Integer.valueOf(456)); Assert.assertEquals(bind.getMap2().get("passWord"), map.get("hmily.map2.passWord")); System.out.println(bind); }
|
@Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; }
|
MapBinder extends AggregateBinder<Map<Object, Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; } }
|
MapBinder extends AggregateBinder<Map<Object, Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; } MapBinder(final Binder.Env env); }
|
MapBinder extends AggregateBinder<Map<Object, Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; } MapBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Map<Object, Object> object); @Override boolean isAllowRecursiveBinding(final Binder.Env source); }
|
MapBinder extends AggregateBinder<Map<Object, Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(propertyName); if (!hasDescendants) { new EntryBinder(propertyName, target, env, elementBinder).bindEntries(env.getSource(), map); } return map.isEmpty() ? null : map; } MapBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Map<Object, Object> object); @Override boolean isAllowRecursiveBinding(final Binder.Env source); }
|
@Test public void testArrayList() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.list[0]", 123); map.put("hmily.list[1]", 234); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>(propertySource, PropertyKeyParse.INSTANCE); Binder binder = Binder.of(configPropertySource); BindData<CollectionPojo> data = BindData.of(DataType.of(CollectionPojo.class), CollectionPojo::new); CollectionPojo bind = binder.bind("hmily", data); Assert.assertEquals(bind.getList().get(0), 123); Assert.assertEquals(bind.getList().get(1), 234); }
|
@Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Collection<Object> object); }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Collection<Object> object); }
|
@Test public void testNotSetArrayList() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.list[0]", 123); map.put("hmily.list[1]", 234); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>(propertySource, PropertyKeyParse.INSTANCE); Binder binder = Binder.of(configPropertySource); BindData<CollectionPojo2> data = BindData.of(DataType.of(CollectionPojo2.class), CollectionPojo2::new); CollectionPojo2 bind = binder.bind("hmily", data); Assert.assertNull(bind); }
|
@Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Collection<Object> object); }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Collection<Object> object); }
|
@Test public void testListGeneric() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.list2[0]", "123"); map.put("hmily.list2[1]", 234); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>(propertySource, PropertyKeyParse.INSTANCE); Binder binder = Binder.of(configPropertySource); BindData<CollectionPojo> data = BindData.of(DataType.of(CollectionPojo.class), CollectionPojo::new); CollectionPojo bind = binder.bind("hmily", data); Assert.assertEquals(bind.getList2().get(0), Integer.valueOf(123)); Assert.assertEquals(bind.getList2().get(1), Integer.valueOf(234)); }
|
@Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Collection<Object> object); }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Collection<Object> object); }
|
@Test public void testArray() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.intArray[0]", 123); map.put("hmily.intArray[1]", 234); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>(propertySource, PropertyKeyParse.INSTANCE); Binder binder = Binder.of(configPropertySource); BindData<CollectionPojo> data = BindData.of(DataType.of(CollectionPojo.class), CollectionPojo::new); CollectionPojo bind = binder.bind("hmily", data); Assert.assertEquals(bind.getIntArray()[0], Integer.valueOf(123)); Assert.assertEquals(bind.getIntArray()[1], Integer.valueOf(234)); }
|
@Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Collection<Object> object); }
|
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : type.getTypeClass(); DataType aggregateType = DataType.of(collectionType); DataType elementType = type.getGenerics().length > 0 ? type.getGenerics()[0] : DataType.of(Object.class); IndexedBinder.IndexedCollectionSupplier result = new IndexedBinder.IndexedCollectionSupplier(() -> CollectionUtils.createFactory().create(collectionType, 0)); bindIndexed(propertyName, target, elementBinder, aggregateType, elementType, result); if (result.wasSupplied()) { return result.get(); } return null; } CollectionBinder(final Binder.Env env); @Override Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder); @Override Object merge(final Supplier<?> targetValue, final Collection<Object> object); }
|
@Test public void testOdd() { assertTrue(MathUtil.isOdd(3)); assertFalse(MathUtil.isOdd(4)); }
|
public static boolean isOdd(int number) { return number % 2 == 1; }
|
MathUtil { public static boolean isOdd(int number) { return number % 2 == 1; } }
|
MathUtil { public static boolean isOdd(int number) { return number % 2 == 1; } }
|
MathUtil { public static boolean isOdd(int number) { return number % 2 == 1; } static boolean isOdd(int number); }
|
MathUtil { public static boolean isOdd(int number) { return number % 2 == 1; } static boolean isOdd(int number); }
|
@Test public void computeTrueAnswers() throws Exception { File configFile = File.createTempFile("test-workload", "toml"); configFile.deleteOnExit(); try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(configFile.getAbsolutePath()))) { writer.write("directory = \"/tmp\"\n" + "[data]\n" + "tstart = 0\n" + "tend = 10_000\n" + "stream-generator = \"RandomStreamGenerator\"\n" + "interarrivals = {distribution = \"FixedDistribution\", value = 1}\n" + "values = {distribution = \"FixedDistribution\", value = 1}\n" + "[workload]\n" + "enable-parallelism = true\n" ); } Configuration conf = new Configuration(configFile); assert conf.getTstart() == 0; long T = conf.getTend(); int Q = 1000; Workload workload = new Workload(); List<Workload.Query> queries = new ArrayList<>(); workload.put("", queries); Random random = new Random(0); for (int q = 0; q < Q; ++q) { long a = Math.floorMod(random.nextLong(), T), b = Math.floorMod(random.nextLong(), T); long l = Math.min(a, b), r = Math.max(a, b); queries.add(new Workload.Query(Workload.Query.Type.COUNT, l, r, 0, null)); } LRMSPopulateWorkload.computeTrueAnswers(conf, workload); for (Workload.Query q : queries) { assertEquals(q.r - q.l + 1, q.trueAnswer.get()); } }
|
static void computeTrueAnswers(Configuration conf, Workload workload) throws Exception { long T0 = conf.getTstart(), T1 = conf.getTend(); ArrayList<LongRange> intervals = new ArrayList<>(); ArrayList<Query> queries = new ArrayList<>(); for (List<Query> classQueries: workload.values()) { for (Query q: classQueries) { queries.add(q); intervals.add(new LongRange(q.l + ":" + q.r, q.l, true, q.r, true)); } } int Q = queries.size(); Builder builder = new Builder(intervals.toArray(new LongRange[Q]), T0, T1); LongRangeMultiSet lrms = builder.getMultiSet(false, true); if (!conf.isWorkloadParallelismEnabled()) { int[] matchedIndexes = new int[Q]; long[] N = {0}; conf.getStreamGenerator().generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (++N[0] % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); }); } else { int nThreads = ForkJoinPool.getCommonPoolParallelism(); assert nThreads > 0; logger.info("# threads = {}", nThreads); long N; { MutableLong nvals = new MutableLong(0L); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { streamGenerator.generate(T0, T1, op -> { if (op.type == StreamGenerator.Operation.Type.APPEND) { nvals.increment(); } }); } N = nvals.toLong(); } IntStream.range(0, nThreads).parallel().forEach(threadNum -> { long Nleft = threadNum * (N / nThreads); long Nright = (threadNum != nThreads - 1) ? Nleft + (N / nThreads) : N; logger.info("Thread {}: [{}, {})", threadNum, Nleft, Nright); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { MutableLong Ncurr = new MutableLong(0L); int[] matchedIndexes = new int[Q]; streamGenerator.generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (Nleft <= Ncurr.toLong() && Ncurr.toLong() < Nright) { if (Ncurr.toLong() % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); } else if (Ncurr.toLong() >= Nright) { return; } Ncurr.increment(); }); } catch (Exception e) { throw new RuntimeException(e); } logger.info("Thread {} done", threadNum); }); } }
|
LRMSPopulateWorkload { static void computeTrueAnswers(Configuration conf, Workload workload) throws Exception { long T0 = conf.getTstart(), T1 = conf.getTend(); ArrayList<LongRange> intervals = new ArrayList<>(); ArrayList<Query> queries = new ArrayList<>(); for (List<Query> classQueries: workload.values()) { for (Query q: classQueries) { queries.add(q); intervals.add(new LongRange(q.l + ":" + q.r, q.l, true, q.r, true)); } } int Q = queries.size(); Builder builder = new Builder(intervals.toArray(new LongRange[Q]), T0, T1); LongRangeMultiSet lrms = builder.getMultiSet(false, true); if (!conf.isWorkloadParallelismEnabled()) { int[] matchedIndexes = new int[Q]; long[] N = {0}; conf.getStreamGenerator().generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (++N[0] % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); }); } else { int nThreads = ForkJoinPool.getCommonPoolParallelism(); assert nThreads > 0; logger.info("# threads = {}", nThreads); long N; { MutableLong nvals = new MutableLong(0L); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { streamGenerator.generate(T0, T1, op -> { if (op.type == StreamGenerator.Operation.Type.APPEND) { nvals.increment(); } }); } N = nvals.toLong(); } IntStream.range(0, nThreads).parallel().forEach(threadNum -> { long Nleft = threadNum * (N / nThreads); long Nright = (threadNum != nThreads - 1) ? Nleft + (N / nThreads) : N; logger.info("Thread {}: [{}, {})", threadNum, Nleft, Nright); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { MutableLong Ncurr = new MutableLong(0L); int[] matchedIndexes = new int[Q]; streamGenerator.generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (Nleft <= Ncurr.toLong() && Ncurr.toLong() < Nright) { if (Ncurr.toLong() % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); } else if (Ncurr.toLong() >= Nright) { return; } Ncurr.increment(); }); } catch (Exception e) { throw new RuntimeException(e); } logger.info("Thread {} done", threadNum); }); } } }
|
LRMSPopulateWorkload { static void computeTrueAnswers(Configuration conf, Workload workload) throws Exception { long T0 = conf.getTstart(), T1 = conf.getTend(); ArrayList<LongRange> intervals = new ArrayList<>(); ArrayList<Query> queries = new ArrayList<>(); for (List<Query> classQueries: workload.values()) { for (Query q: classQueries) { queries.add(q); intervals.add(new LongRange(q.l + ":" + q.r, q.l, true, q.r, true)); } } int Q = queries.size(); Builder builder = new Builder(intervals.toArray(new LongRange[Q]), T0, T1); LongRangeMultiSet lrms = builder.getMultiSet(false, true); if (!conf.isWorkloadParallelismEnabled()) { int[] matchedIndexes = new int[Q]; long[] N = {0}; conf.getStreamGenerator().generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (++N[0] % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); }); } else { int nThreads = ForkJoinPool.getCommonPoolParallelism(); assert nThreads > 0; logger.info("# threads = {}", nThreads); long N; { MutableLong nvals = new MutableLong(0L); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { streamGenerator.generate(T0, T1, op -> { if (op.type == StreamGenerator.Operation.Type.APPEND) { nvals.increment(); } }); } N = nvals.toLong(); } IntStream.range(0, nThreads).parallel().forEach(threadNum -> { long Nleft = threadNum * (N / nThreads); long Nright = (threadNum != nThreads - 1) ? Nleft + (N / nThreads) : N; logger.info("Thread {}: [{}, {})", threadNum, Nleft, Nright); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { MutableLong Ncurr = new MutableLong(0L); int[] matchedIndexes = new int[Q]; streamGenerator.generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (Nleft <= Ncurr.toLong() && Ncurr.toLong() < Nright) { if (Ncurr.toLong() % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); } else if (Ncurr.toLong() >= Nright) { return; } Ncurr.increment(); }); } catch (Exception e) { throw new RuntimeException(e); } logger.info("Thread {} done", threadNum); }); } } }
|
LRMSPopulateWorkload { static void computeTrueAnswers(Configuration conf, Workload workload) throws Exception { long T0 = conf.getTstart(), T1 = conf.getTend(); ArrayList<LongRange> intervals = new ArrayList<>(); ArrayList<Query> queries = new ArrayList<>(); for (List<Query> classQueries: workload.values()) { for (Query q: classQueries) { queries.add(q); intervals.add(new LongRange(q.l + ":" + q.r, q.l, true, q.r, true)); } } int Q = queries.size(); Builder builder = new Builder(intervals.toArray(new LongRange[Q]), T0, T1); LongRangeMultiSet lrms = builder.getMultiSet(false, true); if (!conf.isWorkloadParallelismEnabled()) { int[] matchedIndexes = new int[Q]; long[] N = {0}; conf.getStreamGenerator().generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (++N[0] % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); }); } else { int nThreads = ForkJoinPool.getCommonPoolParallelism(); assert nThreads > 0; logger.info("# threads = {}", nThreads); long N; { MutableLong nvals = new MutableLong(0L); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { streamGenerator.generate(T0, T1, op -> { if (op.type == StreamGenerator.Operation.Type.APPEND) { nvals.increment(); } }); } N = nvals.toLong(); } IntStream.range(0, nThreads).parallel().forEach(threadNum -> { long Nleft = threadNum * (N / nThreads); long Nright = (threadNum != nThreads - 1) ? Nleft + (N / nThreads) : N; logger.info("Thread {}: [{}, {})", threadNum, Nleft, Nright); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { MutableLong Ncurr = new MutableLong(0L); int[] matchedIndexes = new int[Q]; streamGenerator.generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (Nleft <= Ncurr.toLong() && Ncurr.toLong() < Nright) { if (Ncurr.toLong() % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); } else if (Ncurr.toLong() >= Nright) { return; } Ncurr.increment(); }); } catch (Exception e) { throw new RuntimeException(e); } logger.info("Thread {} done", threadNum); }); } } static void main(String[] args); }
|
LRMSPopulateWorkload { static void computeTrueAnswers(Configuration conf, Workload workload) throws Exception { long T0 = conf.getTstart(), T1 = conf.getTend(); ArrayList<LongRange> intervals = new ArrayList<>(); ArrayList<Query> queries = new ArrayList<>(); for (List<Query> classQueries: workload.values()) { for (Query q: classQueries) { queries.add(q); intervals.add(new LongRange(q.l + ":" + q.r, q.l, true, q.r, true)); } } int Q = queries.size(); Builder builder = new Builder(intervals.toArray(new LongRange[Q]), T0, T1); LongRangeMultiSet lrms = builder.getMultiSet(false, true); if (!conf.isWorkloadParallelismEnabled()) { int[] matchedIndexes = new int[Q]; long[] N = {0}; conf.getStreamGenerator().generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (++N[0] % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); }); } else { int nThreads = ForkJoinPool.getCommonPoolParallelism(); assert nThreads > 0; logger.info("# threads = {}", nThreads); long N; { MutableLong nvals = new MutableLong(0L); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { streamGenerator.generate(T0, T1, op -> { if (op.type == StreamGenerator.Operation.Type.APPEND) { nvals.increment(); } }); } N = nvals.toLong(); } IntStream.range(0, nThreads).parallel().forEach(threadNum -> { long Nleft = threadNum * (N / nThreads); long Nright = (threadNum != nThreads - 1) ? Nleft + (N / nThreads) : N; logger.info("Thread {}: [{}, {})", threadNum, Nleft, Nright); try (StreamGenerator streamGenerator = conf.getStreamGenerator()) { MutableLong Ncurr = new MutableLong(0L); int[] matchedIndexes = new int[Q]; streamGenerator.generate(T0, T1, op -> { if (op.type != StreamGenerator.Operation.Type.APPEND) { return; } if (Nleft <= Ncurr.toLong() && Ncurr.toLong() < Nright) { if (Ncurr.toLong() % 1_000_000 == 0) logger.info("t = {}", op.timestamp); processDataPoint(queries, lrms, matchedIndexes, op.timestamp, op.value); } else if (Ncurr.toLong() >= Nright) { return; } Ncurr.increment(); }); } catch (Exception e) { throw new RuntimeException(e); } logger.info("Thread {} done", threadNum); }); } } static void main(String[] args); }
|
@Test public void getFirstContainingTime() throws Exception { GenericWindowing exp = new GenericWindowing(new ExponentialWindowLengths(2)); assertEquals(101, exp.getFirstContainingTime(98, 99, 100)); assertEquals(103, exp.getFirstContainingTime(96, 99, 100)); assertEquals(107, exp.getFirstContainingTime(92, 99, 100)); assertEquals(115, exp.getFirstContainingTime(84, 99, 100)); }
|
@Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } }
|
GenericWindowing implements Windowing { @Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } } }
|
GenericWindowing implements Windowing { @Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } } GenericWindowing(WindowLengthsSequence windowLengths); }
|
GenericWindowing implements Windowing { @Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } } GenericWindowing(WindowLengthsSequence windowLengths); @Override long getFirstContainingTime(long Tl, long Tr, long T); @Override long getSizeOfFirstWindow(); @Override List<Long> getWindowsCoveringUpto(long N); }
|
GenericWindowing implements Windowing { @Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } } GenericWindowing(WindowLengthsSequence windowLengths); @Override long getFirstContainingTime(long Tl, long Tr, long T); @Override long getSizeOfFirstWindow(); @Override List<Long> getWindowsCoveringUpto(long N); }
|
@Test public void getSizeOfFirstWindow() throws Exception { GenericWindowing exp = new GenericWindowing(new ExponentialWindowLengths(2)); assertEquals(1, exp.getSizeOfFirstWindow(), 1); final long S = 2492; GenericWindowing rp = new GenericWindowing(new WindowLengthsSequence() { private long i = 1; @Override public long nextWindowLength() { return i++ * S; } }); assertEquals(S, rp.getSizeOfFirstWindow()); }
|
@Override public long getSizeOfFirstWindow() { return firstWindowLength; }
|
GenericWindowing implements Windowing { @Override public long getSizeOfFirstWindow() { return firstWindowLength; } }
|
GenericWindowing implements Windowing { @Override public long getSizeOfFirstWindow() { return firstWindowLength; } GenericWindowing(WindowLengthsSequence windowLengths); }
|
GenericWindowing implements Windowing { @Override public long getSizeOfFirstWindow() { return firstWindowLength; } GenericWindowing(WindowLengthsSequence windowLengths); @Override long getFirstContainingTime(long Tl, long Tr, long T); @Override long getSizeOfFirstWindow(); @Override List<Long> getWindowsCoveringUpto(long N); }
|
GenericWindowing implements Windowing { @Override public long getSizeOfFirstWindow() { return firstWindowLength; } GenericWindowing(WindowLengthsSequence windowLengths); @Override long getFirstContainingTime(long Tl, long Tr, long T); @Override long getSizeOfFirstWindow(); @Override List<Long> getWindowsCoveringUpto(long N); }
|
@Test public void getWindowsCoveringUpto() throws Exception { GenericWindowing exp = new GenericWindowing(new ExponentialWindowLengths(2)); assertThat(exp.getWindowsCoveringUpto(62), is(Arrays.asList(1L, 2L, 4L, 8L, 16L))); assertThat(exp.getWindowsCoveringUpto(63), is(Arrays.asList(1L, 2L, 4L, 8L, 16L, 32L))); }
|
@Override public List<Long> getWindowsCoveringUpto(long N) { if (N <= 0) return Collections.emptyList(); addWindowsPastMarker(N); List<Long> ret = new ArrayList<>(); long prevMarker = 0; for (long currMarker: windowStartMarkers) { if (currMarker == 0) continue; if (currMarker <= N) { ret.add(currMarker - prevMarker); prevMarker = currMarker; } else { break; } } return ret; }
|
GenericWindowing implements Windowing { @Override public List<Long> getWindowsCoveringUpto(long N) { if (N <= 0) return Collections.emptyList(); addWindowsPastMarker(N); List<Long> ret = new ArrayList<>(); long prevMarker = 0; for (long currMarker: windowStartMarkers) { if (currMarker == 0) continue; if (currMarker <= N) { ret.add(currMarker - prevMarker); prevMarker = currMarker; } else { break; } } return ret; } }
|
GenericWindowing implements Windowing { @Override public List<Long> getWindowsCoveringUpto(long N) { if (N <= 0) return Collections.emptyList(); addWindowsPastMarker(N); List<Long> ret = new ArrayList<>(); long prevMarker = 0; for (long currMarker: windowStartMarkers) { if (currMarker == 0) continue; if (currMarker <= N) { ret.add(currMarker - prevMarker); prevMarker = currMarker; } else { break; } } return ret; } GenericWindowing(WindowLengthsSequence windowLengths); }
|
GenericWindowing implements Windowing { @Override public List<Long> getWindowsCoveringUpto(long N) { if (N <= 0) return Collections.emptyList(); addWindowsPastMarker(N); List<Long> ret = new ArrayList<>(); long prevMarker = 0; for (long currMarker: windowStartMarkers) { if (currMarker == 0) continue; if (currMarker <= N) { ret.add(currMarker - prevMarker); prevMarker = currMarker; } else { break; } } return ret; } GenericWindowing(WindowLengthsSequence windowLengths); @Override long getFirstContainingTime(long Tl, long Tr, long T); @Override long getSizeOfFirstWindow(); @Override List<Long> getWindowsCoveringUpto(long N); }
|
GenericWindowing implements Windowing { @Override public List<Long> getWindowsCoveringUpto(long N) { if (N <= 0) return Collections.emptyList(); addWindowsPastMarker(N); List<Long> ret = new ArrayList<>(); long prevMarker = 0; for (long currMarker: windowStartMarkers) { if (currMarker == 0) continue; if (currMarker <= N) { ret.add(currMarker - prevMarker); prevMarker = currMarker; } else { break; } } return ret; } GenericWindowing(WindowLengthsSequence windowLengths); @Override long getFirstContainingTime(long Tl, long Tr, long T); @Override long getSizeOfFirstWindow(); @Override List<Long> getWindowsCoveringUpto(long N); }
|
@Test public void worldFromConfValidName() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.WORLD_NAME, "test"); when(Bukkit.getWorld("test")).thenReturn(mock(World.class)); World w = WorldLoader.worldFromConfig(conf, false); Assert.assertNotNull(w); }
|
@Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void blockLocationFromConfigValid() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.X, 6); conf.set(WorldLoader.Y, 0); conf.set(WorldLoader.Z, -4); conf.set(WorldLoader.WORLD_NAME, "test"); when(Bukkit.getWorld("test")).thenReturn(mock(World.class)); Location loc = WorldLoader.blockLocationFromConfig(conf, false); Assert.assertNotNull(loc); }
|
@Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void blockLocationFromConfigNoWorld() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.X, 6); conf.set(WorldLoader.Y, 0); conf.set(WorldLoader.Z, -4); Location loc = WorldLoader.blockLocationFromConfig(conf, false); Assert.assertNull(loc); }
|
@Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void blockLocationFromConfigInvalidPos() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.X, 6); conf.set(WorldLoader.Y, "ye"); conf.set(WorldLoader.Z, -4); conf.set(WorldLoader.WORLD_NAME, "test"); when(Bukkit.getWorld("test")).thenReturn(mock(World.class)); Location loc = WorldLoader.blockLocationFromConfig(conf, false); Assert.assertNull(loc); }
|
@Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); return loc; } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void createDataFolderCreatesCorrectPath() throws IOException { File file = FileUtils.createDatafolderFile(plugin, "test.json"); assertTrue(file.exists()); assertTrue(file.isFile()); assertEquals(dataFolder.getRoot().getPath() + File.separator + "test.json", file.getPath()); }
|
@NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void createDataFolderCreatesCorrectSubPath() throws IOException { File file = FileUtils.createDatafolderFile(plugin, "testii", "test.json"); assertTrue(file.exists()); assertTrue(file.isFile()); String pathExpected = dataFolder.getRoot().getPath() + File.separator + "testii" + File.separator + "test.json"; assertEquals(pathExpected, file.getPath()); }
|
@NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void createDataFolderCreatesCorrectSubSubPath() throws IOException { File file = FileUtils.createDatafolderFile(plugin, "testii", "testii2", "test.json"); assertTrue(file.exists()); assertTrue(file.isFile()); String pathExpected = dataFolder.getRoot().getPath() + File.separator + "testii" + File.separator + "testii2" + File.separator + "test.json"; assertEquals(pathExpected, file.getPath()); }
|
@NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void writeFailsWhenGivenFileIsFolder() throws IOException { assertFalse(FileUtils.write("whatever", plugin)); }
|
public static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path) throws IOException { return write(string, createDatafolderFile(plugin, path)); }
|
FileUtils { public static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path) throws IOException { return write(string, createDatafolderFile(plugin, path)); } }
|
FileUtils { public static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path) throws IOException { return write(string, createDatafolderFile(plugin, path)); } }
|
FileUtils { public static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path) throws IOException { return write(string, createDatafolderFile(plugin, path)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { public static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path) throws IOException { return write(string, createDatafolderFile(plugin, path)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void getDatafolderFileDoesNotCreateAnything() { File file = FileUtils.getDatafolderFile(plugin, "notafile.txt"); assertFalse(file.exists()); }
|
@NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test(expected = IllegalArgumentException.class) public void getDatafolderFileWithNullElementReturnsNull() { FileUtils.getDatafolderFile(plugin, null, "notafile.txt"); }
|
@NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test(expected = IllegalArgumentException.class) public void getDatafolderFileWithNullElementReturnsNull2() { FileUtils.getDatafolderFile(plugin, "folder", null); }
|
@NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + joinPath(File.separatorChar, false, children)); } } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void worldFromConfValidUUID() { YamlConfiguration conf = new YamlConfiguration(); UUID uuid = UUID.randomUUID(); conf.set(WorldLoader.WORLD_UID, uuid.toString()); when(Bukkit.getWorld(uuid)).thenReturn(mock(World.class)); World w = WorldLoader.worldFromConfig(conf, true); Assert.assertNotNull(w); }
|
@Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void getFilesReturnAllFilesInFolder() throws IOException { Random random = new Random(); int nrOfFiles = random.nextInt(5) + 10; List<File> createdFiles = new ArrayList<>(); for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "file" + i); createdFiles.add(file); assertTrue(file.createNewFile()); } List<File> files = FileUtils.getFiles(plugin); assertNotNull(files); assertEquals(nrOfFiles, files.size()); Collections.sort(createdFiles); Collections.sort(files); assertEquals(createdFiles, files); }
|
@Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); }
|
FileUtils { @Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); } }
|
FileUtils { @Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); } }
|
FileUtils { @Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void getFilesInEmptyFolderReturnEmptyList() { List<File> files = FileUtils.getFiles(plugin); assertNotNull(files); assertTrue(files.isEmpty()); }
|
@Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); }
|
FileUtils { @Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); } }
|
FileUtils { @Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); } }
|
FileUtils { @Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void getFileNamesIgnoresFolders() throws IOException { Random random = new Random(); int nrOfFiles = random.nextInt(5) + 40; List<String> createdFiles = new ArrayList<>(); for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "file" + i); if (random.nextBoolean()) { createdFiles.add(file.getName()); assertTrue(file.createNewFile()); } else { assertTrue(file.mkdir()); } } List<String> files = FileUtils.getFileNames(plugin); assertNotNull(files); Collections.sort(createdFiles); Collections.sort(files); assertEquals(createdFiles, files); }
|
@Nullable public static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath) { List<File> files = getFiles(plugin, subPath); if (files == null) { return null; } return getFileNames(files); }
|
FileUtils { @Nullable public static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath) { List<File> files = getFiles(plugin, subPath); if (files == null) { return null; } return getFileNames(files); } }
|
FileUtils { @Nullable public static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath) { List<File> files = getFiles(plugin, subPath); if (files == null) { return null; } return getFileNames(files); } }
|
FileUtils { @Nullable public static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath) { List<File> files = getFiles(plugin, subPath); if (files == null) { return null; } return getFileNames(files); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @Nullable public static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath) { List<File> files = getFiles(plugin, subPath); if (files == null) { return null; } return getFileNames(files); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void getRecursiveFilesIsSameAsGetFilesWhenNoSubfolders() throws IOException { Random random = new Random(); int nrOfFiles = random.nextInt(5) + 40; List<File> createdFiles = new ArrayList<>(); for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "recfile" + i); createdFiles.add(file); assertTrue(file.createNewFile()); } List<File> files = FileUtils.getRecursiveFiles(false, plugin); assertEquals(nrOfFiles, files.size()); Collections.sort(createdFiles); Collections.sort(files); assertEquals(createdFiles, files); }
|
@NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void getRecursiveFilesIgnoresFilesWithHyphenWhenTrue() throws IOException { Random random = new Random(); int nrOfFiles = random.nextInt(5) + 40; List<File> createdFiles = new ArrayList<>(); for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "recfile" + i); createdFiles.add(file); assertTrue(file.createNewFile()); } for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "-recfile" + i); assertTrue(file.createNewFile()); } List<File> files = FileUtils.getRecursiveFiles(true, plugin); Collections.sort(createdFiles); Collections.sort(files); assertEquals(createdFiles, files); }
|
@NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void getRecursiveFilesIncludesFilesWithHyphenWhenFalse() throws IOException { Random random = new Random(); int nrOfFiles = random.nextInt(5) + 40; List<File> createdFiles = new ArrayList<>(); for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "recfile" + i); createdFiles.add(file); assertTrue(file.createNewFile()); } for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "-recfile" + i); createdFiles.add(file); assertTrue(file.createNewFile()); } List<File> files = FileUtils.getRecursiveFiles(false, plugin); Collections.sort(createdFiles); Collections.sort(files); assertEquals(createdFiles, files); }
|
@NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void getRecursiveFilesIncludesFoldersWithHyphenWhenFalse() throws IOException { Random random = new Random(); int nrOfFiles = random.nextInt(5) + 40; List<File> createdFiles = new ArrayList<>(); for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "recfile" + i); createdFiles.add(file); assertTrue(file.createNewFile()); } for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "-recfile" + i); createdFiles.add(file); assertTrue(file.createNewFile()); } List<File> files = FileUtils.getRecursiveFiles(false, plugin); Collections.sort(createdFiles); Collections.sort(files); assertEquals(createdFiles, files); }
|
@NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void getInternalFileStreamBinFileEquals() throws IOException { String s = "/" + String.join("/", TEST_BIN_FILE_WITH_DIR_PATH); InputStream isE = FileUtilsTest.class.getResourceAsStream(s); assertNotNull(isE); InputStream isA = FileUtils.getInternalFileStream(TEST_BIN_FILE_WITH_DIR_PATH); assertNotNull(isA); assertArrayEquals(IOUtils.toByteArray(isE), IOUtils.toByteArray(isA)); }
|
@Nullable public static InputStream getInternalFileStream(@NotNull String... absPath) { return getInternalFileStream(FileUtils.class, absPath); }
|
FileUtils { @Nullable public static InputStream getInternalFileStream(@NotNull String... absPath) { return getInternalFileStream(FileUtils.class, absPath); } }
|
FileUtils { @Nullable public static InputStream getInternalFileStream(@NotNull String... absPath) { return getInternalFileStream(FileUtils.class, absPath); } }
|
FileUtils { @Nullable public static InputStream getInternalFileStream(@NotNull String... absPath) { return getInternalFileStream(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @Nullable public static InputStream getInternalFileStream(@NotNull String... absPath) { return getInternalFileStream(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void readInternalFileReadsTestFileCorrectly() throws IOException { String s = "/" + String.join("/", TEST_FILE_WITH_DIR_PATH); InputStream is = FileUtilsTest.class.getResourceAsStream(s); assertNotNull(is); String fileContent = IOUtils.toString(is); assertEquals(fileContent, FileUtils.readInternalFile(TEST_FILE_WITH_DIR_PATH)); }
|
@Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void readInternalFileReadsTestFileCorrectly2() throws IOException { String s = "/" + String.join("/", TEST_FILE_WITHOUT_DIR_PATH); InputStream is = FileUtilsTest.class.getResourceAsStream(s); assertNotNull(is); String fileContent = IOUtils.toString(is); assertEquals(fileContent, FileUtils.readInternalFile(TEST_FILE_WITHOUT_DIR_PATH)); }
|
@Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void worldFromConfInValidName() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.WORLD_NAME, "aa"); World w = WorldLoader.worldFromConfig(conf, true); Assert.assertNull(w); }
|
@Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void readInternalFileHandleNonExistingFileCorrectly() throws IOException { assertNull(FileUtils.readInternalFile("non-existing")); }
|
@Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); }
|
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSafely(@NotNull File file); static boolean createFolder(@NotNull Plugin plugin, @NotNull String... children); static boolean createFolderSafely(@NotNull File folder); static boolean writeFromInternal(Plugin plugin, String[] externalPath, String... internalPath); static boolean writeFromInternal(Plugin plugin, String[] externalPath, Class<?> resourceClass,
String... internalPath); static boolean writeFromInternal(Plugin plugin, Class<?> resourceClass, String... path); static boolean writeFromInternal(Plugin plugin, String... path); static boolean writeFromInternal(File outFile, String... internalPath); static boolean writeFromInternal(File outFile, Class<?> resourceClass, String... internalPath); static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path); static boolean write(@NotNull String string, @NotNull File file); static boolean save(@NotNull InputStream in, @NotNull Plugin plugin, @NotNull String... path); static boolean save(@NotNull InputStream in, @NotNull File file); static String[] splitAtSlash(String path); @NotNull static String joinPath(String... path); @NotNull static String joinPath(boolean abs, String... path); @NotNull static String joinPath(char delimiter, boolean abs, String... path); static void extractInternalFolder(@NotNull Plugin plugin, @NotNull File file, @NotNull String... folderPath); @NotNull static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); @Nullable static String read(@NotNull Plugin plugin, @NotNull String... path); @Nullable static String read(@NotNull File file); @Nullable static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath); @Nullable static List<File> getFiles(@NotNull File folder); @Nullable static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath); @NotNull static List<String> getFileNames(@NotNull List<File> files); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin,
@NotNull String... children); @NotNull static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull File file); @Nullable static InputStream getInternalFileStream(@NotNull String... absPath); @Nullable static InputStream getInternalFileStream(@NotNull Class<?> resourceClass, @NotNull String... absPath); @Nullable static String readInternalFile(@NotNull String... absPath); @Nullable static String readInternalFile(@NotNull Class<?> resourceClass, @NotNull String... absPath); static Logger logger; }
|
@Test public void testCountOneEqualElement() { int amount = 16; ItemStack item = new ItemStack(Material.APPLE, amount); Inventory inv = mock(Inventory.class); when(inv.getContents()).thenReturn(new ItemStack[] {item}); Assert.assertEquals(amount, InventoryUtil.count(inv, item)); }
|
public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
@Test public void testCountNoItems() { Inventory inv = mock(Inventory.class); when(inv.getContents()).thenReturn(new ItemStack[] {}); Assert.assertEquals(0, InventoryUtil.count(inv, new ItemStack(Material.APPLE))); }
|
public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
@Test public void testCountDuplicate() { int amount = 16; ItemStack item = new ItemStack(Material.APPLE, amount); Inventory inv = mock(Inventory.class); when(inv.getContents()).thenReturn(new ItemStack[] {item, item}); Assert.assertEquals(2 * amount, InventoryUtil.count(inv, item)); }
|
public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
@Test public void testCountDuplicateNewInstance() { int amount = 16; ItemStack itemA = new ItemStack(Material.APPLE, amount); ItemStack itemB = new ItemStack(Material.APPLE, amount * 2); Inventory inv = mock(Inventory.class); when(inv.getContents()).thenReturn(new ItemStack[] {itemA, itemB}); assertTrue(itemA.isSimilar(itemB)); Assert.assertEquals(amount * 3, InventoryUtil.count(inv, itemA)); }
|
public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
@Test public void testCountOtherItems() { int amount = 16; ItemStack itemA = new ItemStack(Material.APPLE, amount); ItemStack itemB = new ItemStack(Material.GOLDEN_APPLE, amount / 2); Inventory inv = mock(Inventory.class); when(inv.getContents()).thenReturn(new ItemStack[] {itemA, itemB}); Assert.assertEquals(amount, InventoryUtil.count(inv, itemA)); }
|
public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory inv, @NotNull final Material type, final int amount,
final MaterialData data); static void removeInvItem(final Inventory inv, final ItemStack item, final boolean matOnly); static void removeInvItem(@NotNull final Inventory inv, @NotNull final ItemStack item); static void removeInvMat(@NotNull final Inventory inv, @NotNull final Material material, final int amount); static boolean contains(@Nullable final Inventory inv, @Nullable final ItemStack item, int amount); static int getTotalItems(final Inventory inv, final Material type); static int countItems(@NotNull final Player player, final Material material); static int countItems(@NotNull final Player player, final Material material, final short damageValue); static int count(@NotNull Inventory inv, @NotNull ItemStack item); @SuppressWarnings("deprecation") static boolean canHold(@NotNull final Player player, final ItemStack item); static boolean canHold(final Player player, @NotNull final Material material, final byte data,
final int quantity); static int emptySlots(final Inventory inv); @NotNull static ItemStack getPlayerSkull(@NotNull final OfflinePlayer player); static ItemStack[] getPlayerArmor(@Nullable Inventory inv); }
|
@Test(expected = FileNotFoundException.class) public void saveDefaultResourcesNotExistingWhenNotCreating() throws IOException { ConfigUtil.saveDefaultResources(plugin, false, NON_EXISTING_TEST_FILE_WITH_DIR_PATH); }
|
public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, boolean create, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, @NotNull Class<?> resourceJar, boolean create,
@NotNull String... resources); @Nullable static FileConfiguration getYaml(@NotNull Plugin plugin, String... filename); @Nullable static FileConfiguration getYaml(@NotNull File file); @NotNull static FileConfiguration getYamlOrDefault(@NotNull Plugin plugin, @NotNull FileConfiguration def,
String... filename); @NotNull static FileConfiguration getYamlOrDefault(@NotNull File file, @NotNull FileConfiguration def); static boolean saveYaml(@NotNull Plugin plugin, FileConfiguration conf, String... savePath); static boolean saveYaml(@Nullable ConfigurationSection conf, @Nullable File file); @NotNull static Map<String, Object> getMapSection(@NotNull ConfigurationSection conf, @NotNull String path); @NotNull static Map<String, Object> getMapSection(@Nullable Object obj); @NotNull static ConfigurationSection getSection(@NotNull Object obj); @NotNull static ConfigurationSection getSectionFromMap(@NotNull Map<String, Object> map); static boolean isEmpty(@Nullable ConfigurationSection conf); @NotNull static FileConfiguration toFileConf(@NotNull ConfigurationSection conf); static String saveToString(@NotNull ConfigurationSection conf); @NotNull static YamlConfiguration loadFromString(@NotNull String yaml); @Nullable static YamlConfiguration loadFromStringOrNull(@NotNull String yaml); static Set<String> flatKeys(@NotNull ConfigurationSection conf); @Nullable static T get(@NotNull ConfigurationSection conf, @NotNull String path); @Nullable @Contract("_,_,!null->!null") static T get(@NotNull ConfigurationSection conf, @NotNull String path, @Nullable T fallback); @NotNull static ConfigurationSection diff(@NotNull ConfigurationSection confA, @NotNull ConfigurationSection confB); }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, boolean create, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, @NotNull Class<?> resourceJar, boolean create,
@NotNull String... resources); @Nullable static FileConfiguration getYaml(@NotNull Plugin plugin, String... filename); @Nullable static FileConfiguration getYaml(@NotNull File file); @NotNull static FileConfiguration getYamlOrDefault(@NotNull Plugin plugin, @NotNull FileConfiguration def,
String... filename); @NotNull static FileConfiguration getYamlOrDefault(@NotNull File file, @NotNull FileConfiguration def); static boolean saveYaml(@NotNull Plugin plugin, FileConfiguration conf, String... savePath); static boolean saveYaml(@Nullable ConfigurationSection conf, @Nullable File file); @NotNull static Map<String, Object> getMapSection(@NotNull ConfigurationSection conf, @NotNull String path); @NotNull static Map<String, Object> getMapSection(@Nullable Object obj); @NotNull static ConfigurationSection getSection(@NotNull Object obj); @NotNull static ConfigurationSection getSectionFromMap(@NotNull Map<String, Object> map); static boolean isEmpty(@Nullable ConfigurationSection conf); @NotNull static FileConfiguration toFileConf(@NotNull ConfigurationSection conf); static String saveToString(@NotNull ConfigurationSection conf); @NotNull static YamlConfiguration loadFromString(@NotNull String yaml); @Nullable static YamlConfiguration loadFromStringOrNull(@NotNull String yaml); static Set<String> flatKeys(@NotNull ConfigurationSection conf); @Nullable static T get(@NotNull ConfigurationSection conf, @NotNull String path); @Nullable @Contract("_,_,!null->!null") static T get(@NotNull ConfigurationSection conf, @NotNull String path, @Nullable T fallback); @NotNull static ConfigurationSection diff(@NotNull ConfigurationSection confA, @NotNull ConfigurationSection confB); static Logger logger; }
|
@Test public void saveDefaultResourcesDoesNotOverwrite() throws IOException { String content = "yaegstfiuaeifyefgsaiefgipsaefåøæ"; FileUtils.write(content, plugin, TEST_FILE_WITH_DIR_PATH); ConfigUtil.saveDefaultResources(plugin, TEST_FILE_WITH_DIR_PATH); assertEquals(content, FileUtils.read(plugin, TEST_FILE_WITH_DIR_PATH)); }
|
public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, boolean create, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, @NotNull Class<?> resourceJar, boolean create,
@NotNull String... resources); @Nullable static FileConfiguration getYaml(@NotNull Plugin plugin, String... filename); @Nullable static FileConfiguration getYaml(@NotNull File file); @NotNull static FileConfiguration getYamlOrDefault(@NotNull Plugin plugin, @NotNull FileConfiguration def,
String... filename); @NotNull static FileConfiguration getYamlOrDefault(@NotNull File file, @NotNull FileConfiguration def); static boolean saveYaml(@NotNull Plugin plugin, FileConfiguration conf, String... savePath); static boolean saveYaml(@Nullable ConfigurationSection conf, @Nullable File file); @NotNull static Map<String, Object> getMapSection(@NotNull ConfigurationSection conf, @NotNull String path); @NotNull static Map<String, Object> getMapSection(@Nullable Object obj); @NotNull static ConfigurationSection getSection(@NotNull Object obj); @NotNull static ConfigurationSection getSectionFromMap(@NotNull Map<String, Object> map); static boolean isEmpty(@Nullable ConfigurationSection conf); @NotNull static FileConfiguration toFileConf(@NotNull ConfigurationSection conf); static String saveToString(@NotNull ConfigurationSection conf); @NotNull static YamlConfiguration loadFromString(@NotNull String yaml); @Nullable static YamlConfiguration loadFromStringOrNull(@NotNull String yaml); static Set<String> flatKeys(@NotNull ConfigurationSection conf); @Nullable static T get(@NotNull ConfigurationSection conf, @NotNull String path); @Nullable @Contract("_,_,!null->!null") static T get(@NotNull ConfigurationSection conf, @NotNull String path, @Nullable T fallback); @NotNull static ConfigurationSection diff(@NotNull ConfigurationSection confA, @NotNull ConfigurationSection confB); }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, boolean create, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, @NotNull Class<?> resourceJar, boolean create,
@NotNull String... resources); @Nullable static FileConfiguration getYaml(@NotNull Plugin plugin, String... filename); @Nullable static FileConfiguration getYaml(@NotNull File file); @NotNull static FileConfiguration getYamlOrDefault(@NotNull Plugin plugin, @NotNull FileConfiguration def,
String... filename); @NotNull static FileConfiguration getYamlOrDefault(@NotNull File file, @NotNull FileConfiguration def); static boolean saveYaml(@NotNull Plugin plugin, FileConfiguration conf, String... savePath); static boolean saveYaml(@Nullable ConfigurationSection conf, @Nullable File file); @NotNull static Map<String, Object> getMapSection(@NotNull ConfigurationSection conf, @NotNull String path); @NotNull static Map<String, Object> getMapSection(@Nullable Object obj); @NotNull static ConfigurationSection getSection(@NotNull Object obj); @NotNull static ConfigurationSection getSectionFromMap(@NotNull Map<String, Object> map); static boolean isEmpty(@Nullable ConfigurationSection conf); @NotNull static FileConfiguration toFileConf(@NotNull ConfigurationSection conf); static String saveToString(@NotNull ConfigurationSection conf); @NotNull static YamlConfiguration loadFromString(@NotNull String yaml); @Nullable static YamlConfiguration loadFromStringOrNull(@NotNull String yaml); static Set<String> flatKeys(@NotNull ConfigurationSection conf); @Nullable static T get(@NotNull ConfigurationSection conf, @NotNull String path); @Nullable @Contract("_,_,!null->!null") static T get(@NotNull ConfigurationSection conf, @NotNull String path, @Nullable T fallback); @NotNull static ConfigurationSection diff(@NotNull ConfigurationSection confA, @NotNull ConfigurationSection confB); static Logger logger; }
|
@Test public void saveDefaultResourcesSavesMultipleFiles() throws IOException { String[] filesPaths = {TEST_FILE_WITH_DIR_PATH, TEST_FILE_WITHOUT_DIR_PATH, NON_EXISTING_TEST_FILE_WITH_DIR_PATH}; List<File> expectedFiles = new ArrayList<>(); for (String path : filesPaths) { expectedFiles.add(FileUtils.getDatafolderFile(plugin, path.split("[/\\\\]"))); } ConfigUtil.saveDefaultResources(plugin, filesPaths); List<File> savedFiles = FileUtils.getRecursiveFiles(false, plugin); Collections.sort(expectedFiles); Collections.sort(savedFiles); assertEquals(expectedFiles, savedFiles); for (File file : savedFiles) { assertTrue("File " + file + " does not exist", file.exists()); } }
|
public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, boolean create, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, @NotNull Class<?> resourceJar, boolean create,
@NotNull String... resources); @Nullable static FileConfiguration getYaml(@NotNull Plugin plugin, String... filename); @Nullable static FileConfiguration getYaml(@NotNull File file); @NotNull static FileConfiguration getYamlOrDefault(@NotNull Plugin plugin, @NotNull FileConfiguration def,
String... filename); @NotNull static FileConfiguration getYamlOrDefault(@NotNull File file, @NotNull FileConfiguration def); static boolean saveYaml(@NotNull Plugin plugin, FileConfiguration conf, String... savePath); static boolean saveYaml(@Nullable ConfigurationSection conf, @Nullable File file); @NotNull static Map<String, Object> getMapSection(@NotNull ConfigurationSection conf, @NotNull String path); @NotNull static Map<String, Object> getMapSection(@Nullable Object obj); @NotNull static ConfigurationSection getSection(@NotNull Object obj); @NotNull static ConfigurationSection getSectionFromMap(@NotNull Map<String, Object> map); static boolean isEmpty(@Nullable ConfigurationSection conf); @NotNull static FileConfiguration toFileConf(@NotNull ConfigurationSection conf); static String saveToString(@NotNull ConfigurationSection conf); @NotNull static YamlConfiguration loadFromString(@NotNull String yaml); @Nullable static YamlConfiguration loadFromStringOrNull(@NotNull String yaml); static Set<String> flatKeys(@NotNull ConfigurationSection conf); @Nullable static T get(@NotNull ConfigurationSection conf, @NotNull String path); @Nullable @Contract("_,_,!null->!null") static T get(@NotNull ConfigurationSection conf, @NotNull String path, @Nullable T fallback); @NotNull static ConfigurationSection diff(@NotNull ConfigurationSection confA, @NotNull ConfigurationSection confB); }
|
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, boolean create, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, @NotNull Class<?> resourceJar, boolean create,
@NotNull String... resources); @Nullable static FileConfiguration getYaml(@NotNull Plugin plugin, String... filename); @Nullable static FileConfiguration getYaml(@NotNull File file); @NotNull static FileConfiguration getYamlOrDefault(@NotNull Plugin plugin, @NotNull FileConfiguration def,
String... filename); @NotNull static FileConfiguration getYamlOrDefault(@NotNull File file, @NotNull FileConfiguration def); static boolean saveYaml(@NotNull Plugin plugin, FileConfiguration conf, String... savePath); static boolean saveYaml(@Nullable ConfigurationSection conf, @Nullable File file); @NotNull static Map<String, Object> getMapSection(@NotNull ConfigurationSection conf, @NotNull String path); @NotNull static Map<String, Object> getMapSection(@Nullable Object obj); @NotNull static ConfigurationSection getSection(@NotNull Object obj); @NotNull static ConfigurationSection getSectionFromMap(@NotNull Map<String, Object> map); static boolean isEmpty(@Nullable ConfigurationSection conf); @NotNull static FileConfiguration toFileConf(@NotNull ConfigurationSection conf); static String saveToString(@NotNull ConfigurationSection conf); @NotNull static YamlConfiguration loadFromString(@NotNull String yaml); @Nullable static YamlConfiguration loadFromStringOrNull(@NotNull String yaml); static Set<String> flatKeys(@NotNull ConfigurationSection conf); @Nullable static T get(@NotNull ConfigurationSection conf, @NotNull String path); @Nullable @Contract("_,_,!null->!null") static T get(@NotNull ConfigurationSection conf, @NotNull String path, @Nullable T fallback); @NotNull static ConfigurationSection diff(@NotNull ConfigurationSection confA, @NotNull ConfigurationSection confB); static Logger logger; }
|
@Test public void worldFromConfInValidUUID() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.WORLD_UID, UUID.randomUUID()); World w = WorldLoader.worldFromConfig(conf, true); Assert.assertNull(w); }
|
@Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void worldFromConfNullName() { World w = WorldLoader.worldFromConfig(new YamlConfiguration(), false); Assert.assertNull(w); }
|
@Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void worldFromConfNullUUID() { World w = WorldLoader.worldFromConfig(new YamlConfiguration(), true); Assert.assertNull(w); }
|
@Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void worldlessBlockLocFromConfEmpty() { Location loc = WorldLoader.worldlessBlockLocationFromConfig(new YamlConfiguration()); Assert.assertNull(loc); }
|
@Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void worldlessBlockLocFromConfValid() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.X, 4); conf.set(WorldLoader.Y, 0); conf.set(WorldLoader.Z, -4); Location loc = WorldLoader.worldlessBlockLocationFromConfig(conf); Assert.assertNotNull(loc); }
|
@Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void worldlessBlockLocFromConfNotAllKeys() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.X, 4); conf.set(WorldLoader.Z, -4); Location loc = WorldLoader.worldlessBlockLocationFromConfig(conf); Assert.assertNull(loc); }
|
@Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void worldlessBlockLocFromConfWrongType() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.X, "aaaaaa"); conf.set(WorldLoader.Y, 0); conf.set(WorldLoader.Z, -4); Location loc = WorldLoader.worldlessBlockLocationFromConfig(conf); Assert.assertNull(loc); }
|
@Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); }
|
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatException ex) { return null; } } @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }
|
@Test public void testShowDataOnResume() { mPresenter.onViewResumed(); verify(mView).showData(anyString()); }
|
@Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); }
|
MainPresenter extends BaseTypedPresenter<String, Throwable> { @Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); } }
|
MainPresenter extends BaseTypedPresenter<String, Throwable> { @Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); } MainPresenter(ITypedView<String, Throwable> view); }
|
MainPresenter extends BaseTypedPresenter<String, Throwable> { @Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); } MainPresenter(ITypedView<String, Throwable> view); @Override void onViewResumed(); }
|
MainPresenter extends BaseTypedPresenter<String, Throwable> { @Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); } MainPresenter(ITypedView<String, Throwable> view); @Override void onViewResumed(); }
|
@Test public void testShowErrorOnResume() { mPresenter.onViewResumed(); verify(mView).showError(any(Throwable.class)); }
|
@Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); }
|
MainPresenter extends BaseTypedPresenter<String, Throwable> { @Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); } }
|
MainPresenter extends BaseTypedPresenter<String, Throwable> { @Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); } MainPresenter(ITypedView<String, Throwable> view); }
|
MainPresenter extends BaseTypedPresenter<String, Throwable> { @Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); } MainPresenter(ITypedView<String, Throwable> view); @Override void onViewResumed(); }
|
MainPresenter extends BaseTypedPresenter<String, Throwable> { @Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); } MainPresenter(ITypedView<String, Throwable> view); @Override void onViewResumed(); }
|
@Test public void allCards() { Assert.assertEquals(this.jdkDeck.getCards(), this.ecDeck.getCards()); }
|
public ImmutableList<Card> getCards() { return this.cards; }
|
EclipseCollectionsDeckOfCardsAsList { public ImmutableList<Card> getCards() { return this.cards; } }
|
EclipseCollectionsDeckOfCardsAsList { public ImmutableList<Card> getCards() { return this.cards; } EclipseCollectionsDeckOfCardsAsList(); }
|
EclipseCollectionsDeckOfCardsAsList { public ImmutableList<Card> getCards() { return this.cards; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); ImmutableList<Set<Card>> dealHands(
MutableStack<Card> shuffled,
int hands,
int cardsPerHand); ImmutableList<Card> diamonds(); ImmutableList<Card> hearts(); ImmutableList<Card> spades(); ImmutableList<Card> clubs(); Bag<Suit> countsBySuit(); Bag<Rank> countsByRank(); ImmutableList<Card> getCards(); ImmutableListMultimap<Suit, Card> getCardsBySuit(); }
|
EclipseCollectionsDeckOfCardsAsList { public ImmutableList<Card> getCards() { return this.cards; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); ImmutableList<Set<Card>> dealHands(
MutableStack<Card> shuffled,
int hands,
int cardsPerHand); ImmutableList<Card> diamonds(); ImmutableList<Card> hearts(); ImmutableList<Card> spades(); ImmutableList<Card> clubs(); Bag<Suit> countsBySuit(); Bag<Rank> countsByRank(); ImmutableList<Card> getCards(); ImmutableListMultimap<Suit, Card> getCardsBySuit(); }
|
@Test public void forEachWithIndex() { MutableList<String> list = MutableList.empty(); this.testObj.withAll("1", "2", "3", "2", "3", "3") .forEachWithIndex((each, index) -> list.add(each + index)); Assert.assertEquals(MutableList.of("10", "21", "22", "33", "34", "35"), list); }
|
public void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer) { Counter index = new Counter(); this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { biConsumer.accept(key, index.getCount()); index.increment(); } }); }
|
HashBag implements MutableBag<T> { public void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer) { Counter index = new Counter(); this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { biConsumer.accept(key, index.getCount()); index.increment(); } }); } }
|
HashBag implements MutableBag<T> { public void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer) { Counter index = new Counter(); this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { biConsumer.accept(key, index.getCount()); index.increment(); } }); } }
|
HashBag implements MutableBag<T> { public void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer) { Counter index = new Counter(); this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { biConsumer.accept(key, index.getCount()); index.increment(); } }); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { public void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer) { Counter index = new Counter(); this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { biConsumer.accept(key, index.getCount()); index.increment(); } }); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void add() { this.testObj.add("1"); this.testObj.add("2"); this.testObj.add("2"); Assert.assertEquals(MutableBag.of("1", "2", "2"), this.testObj); }
|
@Override public boolean add(T element) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; return true; }
|
HashBag implements MutableBag<T> { @Override public boolean add(T element) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; return true; } }
|
HashBag implements MutableBag<T> { @Override public boolean add(T element) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; return true; } }
|
HashBag implements MutableBag<T> { @Override public boolean add(T element) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; return true; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public boolean add(T element) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; return true; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void remove() { this.testObj.add("1"); this.testObj.add("2"); this.testObj.add("2"); Assert.assertEquals(MutableBag.of("1", "2", "2"), this.testObj); this.testObj.remove("2"); Assert.assertEquals(MutableBag.of("1"), this.testObj); this.testObj.remove("1"); Assert.assertEquals(MutableBag.empty(), this.testObj); }
|
@Override public boolean remove(Object o) { return this.removeOccurrences((T) o, Integer.MAX_VALUE); }
|
HashBag implements MutableBag<T> { @Override public boolean remove(Object o) { return this.removeOccurrences((T) o, Integer.MAX_VALUE); } }
|
HashBag implements MutableBag<T> { @Override public boolean remove(Object o) { return this.removeOccurrences((T) o, Integer.MAX_VALUE); } }
|
HashBag implements MutableBag<T> { @Override public boolean remove(Object o) { return this.removeOccurrences((T) o, Integer.MAX_VALUE); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public boolean remove(Object o) { return this.removeOccurrences((T) o, Integer.MAX_VALUE); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void containsAll() { Assert.assertTrue(this.testObj.containsAll(MutableList.empty())); Assert.assertFalse(this.testObj.containsAll(MutableList.of("1"))); this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertTrue(this.testObj.containsAll(MutableList.of("1"))); Assert.assertTrue(this.testObj.containsAll(MutableList.of("1", "2"))); Assert.assertFalse(this.testObj.containsAll(MutableList.of("1", "2", "4"))); }
|
@Override public boolean containsAll(Collection<?> c) { return c.stream().allMatch(each -> this.backingMap.containsKey(each)); }
|
HashBag implements MutableBag<T> { @Override public boolean containsAll(Collection<?> c) { return c.stream().allMatch(each -> this.backingMap.containsKey(each)); } }
|
HashBag implements MutableBag<T> { @Override public boolean containsAll(Collection<?> c) { return c.stream().allMatch(each -> this.backingMap.containsKey(each)); } }
|
HashBag implements MutableBag<T> { @Override public boolean containsAll(Collection<?> c) { return c.stream().allMatch(each -> this.backingMap.containsKey(each)); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public boolean containsAll(Collection<?> c) { return c.stream().allMatch(each -> this.backingMap.containsKey(each)); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void addAll() { Assert.assertFalse(this.testObj.addAll(MutableList.empty())); Assert.assertEquals(MutableBag.empty(), this.testObj); Assert.assertTrue(this.testObj.addAll(MutableList.of("1", "2", "2"))); Assert.assertEquals(MutableBag.of("1", "2", "2"), this.testObj); }
|
@Override public boolean addAll(Collection<? extends T> c) { int sizeBefore = this.size; c.forEach(each -> this.addOccurrence(each)); return sizeBefore != this.size; }
|
HashBag implements MutableBag<T> { @Override public boolean addAll(Collection<? extends T> c) { int sizeBefore = this.size; c.forEach(each -> this.addOccurrence(each)); return sizeBefore != this.size; } }
|
HashBag implements MutableBag<T> { @Override public boolean addAll(Collection<? extends T> c) { int sizeBefore = this.size; c.forEach(each -> this.addOccurrence(each)); return sizeBefore != this.size; } }
|
HashBag implements MutableBag<T> { @Override public boolean addAll(Collection<? extends T> c) { int sizeBefore = this.size; c.forEach(each -> this.addOccurrence(each)); return sizeBefore != this.size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public boolean addAll(Collection<? extends T> c) { int sizeBefore = this.size; c.forEach(each -> this.addOccurrence(each)); return sizeBefore != this.size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void removeAll() { Assert.assertFalse(this.testObj.removeAll(MutableList.empty())); this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertTrue(this.testObj.removeAll(MutableList.of("1", "2"))); Assert.assertEquals(MutableBag.of("3", "3", "3"), this.testObj); Assert.assertFalse(this.testObj.removeAll(MutableList.of("4"))); Assert.assertTrue(this.testObj.removeAll(MutableList.of("3", "3", "3"))); Assert.assertEquals(MutableBag.empty(), this.testObj); }
|
@Override public boolean removeAll(Collection<?> c) { int sizeBefore = this.size; c.forEach(each -> this.removeOccurrences((T) each, Integer.MAX_VALUE)); return sizeBefore != this.size; }
|
HashBag implements MutableBag<T> { @Override public boolean removeAll(Collection<?> c) { int sizeBefore = this.size; c.forEach(each -> this.removeOccurrences((T) each, Integer.MAX_VALUE)); return sizeBefore != this.size; } }
|
HashBag implements MutableBag<T> { @Override public boolean removeAll(Collection<?> c) { int sizeBefore = this.size; c.forEach(each -> this.removeOccurrences((T) each, Integer.MAX_VALUE)); return sizeBefore != this.size; } }
|
HashBag implements MutableBag<T> { @Override public boolean removeAll(Collection<?> c) { int sizeBefore = this.size; c.forEach(each -> this.removeOccurrences((T) each, Integer.MAX_VALUE)); return sizeBefore != this.size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public boolean removeAll(Collection<?> c) { int sizeBefore = this.size; c.forEach(each -> this.removeOccurrences((T) each, Integer.MAX_VALUE)); return sizeBefore != this.size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void clear() { this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertFalse(this.testObj.isEmpty()); this.testObj.clear(); Assert.assertTrue(this.testObj.isEmpty()); Assert.assertEquals(0, this.testObj.size()); Assert.assertEquals(0, this.testObj.sizeDistinct()); }
|
@Override public void clear() { this.backingMap.clear(); this.size = 0; }
|
HashBag implements MutableBag<T> { @Override public void clear() { this.backingMap.clear(); this.size = 0; } }
|
HashBag implements MutableBag<T> { @Override public void clear() { this.backingMap.clear(); this.size = 0; } }
|
HashBag implements MutableBag<T> { @Override public void clear() { this.backingMap.clear(); this.size = 0; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public void clear() { this.backingMap.clear(); this.size = 0; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void getOccurrences() { this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertEquals(1, this.testObj.getOccurrences("1")); Assert.assertEquals(2, this.testObj.getOccurrences("2")); Assert.assertEquals(3, this.testObj.getOccurrences("3")); Assert.assertEquals(0, this.testObj.getOccurrences("4")); }
|
@Override public int getOccurrences(T element) { return this.backingMap.getOrDefault(element, 0); }
|
HashBag implements MutableBag<T> { @Override public int getOccurrences(T element) { return this.backingMap.getOrDefault(element, 0); } }
|
HashBag implements MutableBag<T> { @Override public int getOccurrences(T element) { return this.backingMap.getOrDefault(element, 0); } }
|
HashBag implements MutableBag<T> { @Override public int getOccurrences(T element) { return this.backingMap.getOrDefault(element, 0); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public int getOccurrences(T element) { return this.backingMap.getOrDefault(element, 0); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void iterator() { this.testObj.withAll("1", "2", "3", "2", "3", "3"); Iterator<String> iterator = this.testObj.iterator(); Assert.assertEquals("1", iterator.next()); Assert.assertTrue(iterator.hasNext()); iterator.remove(); Assert.assertEquals("2", iterator.next()); iterator.remove(); Assert.assertEquals("2", iterator.next()); Assert.assertEquals("3", iterator.next()); iterator.remove(); Assert.assertEquals("3", iterator.next()); iterator.remove(); Assert.assertEquals("3", iterator.next()); iterator.remove(); Assert.assertFalse(iterator.hasNext()); Assert.assertEquals(MutableBag.of("2"), this.testObj); }
|
@Override public Iterator<T> iterator() { return new BagIterator(); }
|
HashBag implements MutableBag<T> { @Override public Iterator<T> iterator() { return new BagIterator(); } }
|
HashBag implements MutableBag<T> { @Override public Iterator<T> iterator() { return new BagIterator(); } }
|
HashBag implements MutableBag<T> { @Override public Iterator<T> iterator() { return new BagIterator(); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public Iterator<T> iterator() { return new BagIterator(); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void addOccurrence() { this.testObj.addOccurrence("1"); Assert.assertEquals(MutableBag.of("1"), this.testObj); Assert.assertEquals(1, this.testObj.size()); Assert.assertEquals(1, this.testObj.sizeDistinct()); }
|
@Override public boolean addOccurrence(T element) { return this.addOccurrences(element, 1); }
|
HashBag implements MutableBag<T> { @Override public boolean addOccurrence(T element) { return this.addOccurrences(element, 1); } }
|
HashBag implements MutableBag<T> { @Override public boolean addOccurrence(T element) { return this.addOccurrences(element, 1); } }
|
HashBag implements MutableBag<T> { @Override public boolean addOccurrence(T element) { return this.addOccurrences(element, 1); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public boolean addOccurrence(T element) { return this.addOccurrences(element, 1); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void cardsBySuitIsImmutable() { var ecCardsBySuit = this.ecDeck.getCardsBySuit(); Verify.assertThrows( UnsupportedOperationException.class, () -> ecCardsBySuit.get(Suit.CLUBS).castToList().remove(0)); Verify.assertThrows( UnsupportedOperationException.class, () -> ecCardsBySuit.get(Suit.CLUBS).castToList().add(null)); Verify.assertThrows( UnsupportedOperationException.class, ecCardsBySuit.get(Suit.CLUBS).castToList()::clear); }
|
public ImmutableListMultimap<Suit, Card> getCardsBySuit() { return this.cardsBySuit; }
|
EclipseCollectionsDeckOfCardsAsList { public ImmutableListMultimap<Suit, Card> getCardsBySuit() { return this.cardsBySuit; } }
|
EclipseCollectionsDeckOfCardsAsList { public ImmutableListMultimap<Suit, Card> getCardsBySuit() { return this.cardsBySuit; } EclipseCollectionsDeckOfCardsAsList(); }
|
EclipseCollectionsDeckOfCardsAsList { public ImmutableListMultimap<Suit, Card> getCardsBySuit() { return this.cardsBySuit; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); ImmutableList<Set<Card>> dealHands(
MutableStack<Card> shuffled,
int hands,
int cardsPerHand); ImmutableList<Card> diamonds(); ImmutableList<Card> hearts(); ImmutableList<Card> spades(); ImmutableList<Card> clubs(); Bag<Suit> countsBySuit(); Bag<Rank> countsByRank(); ImmutableList<Card> getCards(); ImmutableListMultimap<Suit, Card> getCardsBySuit(); }
|
EclipseCollectionsDeckOfCardsAsList { public ImmutableListMultimap<Suit, Card> getCardsBySuit() { return this.cardsBySuit; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); ImmutableList<Set<Card>> dealHands(
MutableStack<Card> shuffled,
int hands,
int cardsPerHand); ImmutableList<Card> diamonds(); ImmutableList<Card> hearts(); ImmutableList<Card> spades(); ImmutableList<Card> clubs(); Bag<Suit> countsBySuit(); Bag<Rank> countsByRank(); ImmutableList<Card> getCards(); ImmutableListMultimap<Suit, Card> getCardsBySuit(); }
|
@Test public void addOccurrences() { this.testObj.addOccurrences("1", 1); Assert.assertEquals(MutableBag.of("1"), this.testObj); Assert.assertEquals(1, this.testObj.size()); Assert.assertEquals(1, this.testObj.sizeDistinct()); this.testObj.addOccurrences("2", 2); Assert.assertEquals(MutableBag.of("1", "2", "2"), this.testObj); Assert.assertEquals(3, this.testObj.size()); Assert.assertEquals(2, this.testObj.sizeDistinct()); }
|
@Override public boolean addOccurrences(T element, int occurrences) { int sizeBefore = size; Integer merged = this.backingMap.merge(element, occurrences, (existingCount, e) -> existingCount + e); size = size + occurrences; return sizeBefore != size; }
|
HashBag implements MutableBag<T> { @Override public boolean addOccurrences(T element, int occurrences) { int sizeBefore = size; Integer merged = this.backingMap.merge(element, occurrences, (existingCount, e) -> existingCount + e); size = size + occurrences; return sizeBefore != size; } }
|
HashBag implements MutableBag<T> { @Override public boolean addOccurrences(T element, int occurrences) { int sizeBefore = size; Integer merged = this.backingMap.merge(element, occurrences, (existingCount, e) -> existingCount + e); size = size + occurrences; return sizeBefore != size; } }
|
HashBag implements MutableBag<T> { @Override public boolean addOccurrences(T element, int occurrences) { int sizeBefore = size; Integer merged = this.backingMap.merge(element, occurrences, (existingCount, e) -> existingCount + e); size = size + occurrences; return sizeBefore != size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public boolean addOccurrences(T element, int occurrences) { int sizeBefore = size; Integer merged = this.backingMap.merge(element, occurrences, (existingCount, e) -> existingCount + e); size = size + occurrences; return sizeBefore != size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void removeOccurrence() { Assert.assertFalse(this.testObj.removeOccurrence("1")); Assert.assertEquals(MutableBag.empty(), this.testObj); this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertTrue(this.testObj.removeOccurrence("1")); Assert.assertEquals(MutableBag.of("2", "2", "3", "3", "3"), this.testObj); Assert.assertTrue(this.testObj.removeOccurrence("2")); Assert.assertEquals(MutableBag.of("2", "3", "3", "3"), this.testObj); Assert.assertTrue(this.testObj.removeOccurrence("2")); Assert.assertEquals(MutableBag.of("3", "3", "3"), this.testObj); Assert.assertFalse(this.testObj.removeOccurrence("2")); }
|
@Override public boolean removeOccurrence(T element) { return this.removeOccurrences(element, 1); }
|
HashBag implements MutableBag<T> { @Override public boolean removeOccurrence(T element) { return this.removeOccurrences(element, 1); } }
|
HashBag implements MutableBag<T> { @Override public boolean removeOccurrence(T element) { return this.removeOccurrences(element, 1); } }
|
HashBag implements MutableBag<T> { @Override public boolean removeOccurrence(T element) { return this.removeOccurrences(element, 1); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public boolean removeOccurrence(T element) { return this.removeOccurrences(element, 1); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void removeOccurrences() { Assert.assertFalse(this.testObj.removeOccurrences("1", 1)); Assert.assertEquals(MutableBag.empty(), this.testObj); this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertTrue(this.testObj.removeOccurrences("1", 2)); Assert.assertEquals(MutableBag.of("2", "2", "3", "3", "3"), this.testObj); Assert.assertEquals(5, this.testObj.size()); Assert.assertTrue(this.testObj.removeOccurrences("2", 2)); Assert.assertEquals(MutableBag.of("3", "3", "3"), this.testObj); Assert.assertFalse(this.testObj.removeOccurrences("2", 2)); }
|
@Override public boolean removeOccurrences(T element, int occurrences) { int sizeBefore = size; Integer existing = this.backingMap.get(element); if (existing != null) { Integer newCount = existing - occurrences; if (newCount <= 0) { this.backingMap.remove(element); size = size - existing; } else { this.backingMap.put(element, newCount); size = size - occurrences; } } return sizeBefore != size; }
|
HashBag implements MutableBag<T> { @Override public boolean removeOccurrences(T element, int occurrences) { int sizeBefore = size; Integer existing = this.backingMap.get(element); if (existing != null) { Integer newCount = existing - occurrences; if (newCount <= 0) { this.backingMap.remove(element); size = size - existing; } else { this.backingMap.put(element, newCount); size = size - occurrences; } } return sizeBefore != size; } }
|
HashBag implements MutableBag<T> { @Override public boolean removeOccurrences(T element, int occurrences) { int sizeBefore = size; Integer existing = this.backingMap.get(element); if (existing != null) { Integer newCount = existing - occurrences; if (newCount <= 0) { this.backingMap.remove(element); size = size - existing; } else { this.backingMap.put(element, newCount); size = size - occurrences; } } return sizeBefore != size; } }
|
HashBag implements MutableBag<T> { @Override public boolean removeOccurrences(T element, int occurrences) { int sizeBefore = size; Integer existing = this.backingMap.get(element); if (existing != null) { Integer newCount = existing - occurrences; if (newCount <= 0) { this.backingMap.remove(element); size = size - existing; } else { this.backingMap.put(element, newCount); size = size - occurrences; } } return sizeBefore != size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public boolean removeOccurrences(T element, int occurrences) { int sizeBefore = size; Integer existing = this.backingMap.get(element); if (existing != null) { Integer newCount = existing - occurrences; if (newCount <= 0) { this.backingMap.remove(element); size = size - existing; } else { this.backingMap.put(element, newCount); size = size - occurrences; } } return sizeBefore != size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void forEachWithOccurrences() { MutableList<String> list = MutableList.empty(); this.testObj.withAll("1", "2", "3", "2", "3", "3") .forEachWithOccurrences((each, count) -> list.add(each + count)); Assert.assertEquals(MutableList.of("11", "22", "33"), list); }
|
@Override public void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer) { this.backingMap.forEach(biConsumer); }
|
HashBag implements MutableBag<T> { @Override public void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer) { this.backingMap.forEach(biConsumer); } }
|
HashBag implements MutableBag<T> { @Override public void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer) { this.backingMap.forEach(biConsumer); } }
|
HashBag implements MutableBag<T> { @Override public void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer) { this.backingMap.forEach(biConsumer); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer) { this.backingMap.forEach(biConsumer); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void forEach() { MutableList<String> list = MutableList.empty(); this.testObj.withAll("1", "2", "3", "2", "3", "3") .forEach((each) -> list.add(each)); Assert.assertEquals(MutableList.of("1", "2", "2", "3", "3", "3"), list); }
|
@Override public void forEach(Consumer<? super T> consumer) { this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { consumer.accept(key); } }); }
|
HashBag implements MutableBag<T> { @Override public void forEach(Consumer<? super T> consumer) { this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { consumer.accept(key); } }); } }
|
HashBag implements MutableBag<T> { @Override public void forEach(Consumer<? super T> consumer) { this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { consumer.accept(key); } }); } }
|
HashBag implements MutableBag<T> { @Override public void forEach(Consumer<? super T> consumer) { this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { consumer.accept(key); } }); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
HashBag implements MutableBag<T> { @Override public void forEach(Consumer<? super T> consumer) { this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { consumer.accept(key); } }); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
|
@Test public void isEmpty() { this.testObj = new UnmodifiableArrayListMultimap(new ArrayListMultimap()); Assert.assertTrue(this.testObj.isEmpty()); this.testObj = new UnmodifiableArrayListMultimap(this.inputMultimap); Assert.assertFalse(this.testObj.isEmpty()); }
|
@Override public boolean isEmpty() { return this.BACKING_MULTIMAP.isEmpty(); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean isEmpty() { return this.BACKING_MULTIMAP.isEmpty(); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean isEmpty() { return this.BACKING_MULTIMAP.isEmpty(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean isEmpty() { return this.BACKING_MULTIMAP.isEmpty(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean isEmpty() { return this.BACKING_MULTIMAP.isEmpty(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void get() { MutableList<Integer> value = this.testObj.get("A"); Assert.assertEquals(MutableList.of(1, 2, 3, 1), value); Assert.assertEquals(MutableList.empty(), this.testObj.get("C")); Verify.assertThrows(UnsupportedOperationException.class, () -> value.add(6)); }
|
@Override public MutableList<V> get(Object key) { return this.BACKING_MULTIMAP.get(key).asUnmodifiable(); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> get(Object key) { return this.BACKING_MULTIMAP.get(key).asUnmodifiable(); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> get(Object key) { return this.BACKING_MULTIMAP.get(key).asUnmodifiable(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> get(Object key) { return this.BACKING_MULTIMAP.get(key).asUnmodifiable(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> get(Object key) { return this.BACKING_MULTIMAP.get(key).asUnmodifiable(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void put() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.put("A", 1)); }
|
@Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void get_putIterable() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.put("A", MutableList.of(1))); }
|
@Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void putAll() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.putAll(MutableMap.of("A", MutableList.of(1, 2, 3)))); }
|
@Override public void putAll(Map<? extends K, ? extends RichIterable<V>> map) { throw new UnsupportedOperationException("Not allowed to perform putAll() on " + UnmodifiableArrayListMultimap.class); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void putAll(Map<? extends K, ? extends RichIterable<V>> map) { throw new UnsupportedOperationException("Not allowed to perform putAll() on " + UnmodifiableArrayListMultimap.class); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void putAll(Map<? extends K, ? extends RichIterable<V>> map) { throw new UnsupportedOperationException("Not allowed to perform putAll() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void putAll(Map<? extends K, ? extends RichIterable<V>> map) { throw new UnsupportedOperationException("Not allowed to perform putAll() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void putAll(Map<? extends K, ? extends RichIterable<V>> map) { throw new UnsupportedOperationException("Not allowed to perform putAll() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void countsBySuit() { Assert.assertEquals( this.jdkDeck.countsBySuit().get(Suit.CLUBS).intValue(), this.ecDeck.countsBySuit().occurrencesOf(Suit.CLUBS)); }
|
public Bag<Suit> countsBySuit() { return null; }
|
EclipseCollectionsDeckOfCardsAsList { public Bag<Suit> countsBySuit() { return null; } }
|
EclipseCollectionsDeckOfCardsAsList { public Bag<Suit> countsBySuit() { return null; } EclipseCollectionsDeckOfCardsAsList(); }
|
EclipseCollectionsDeckOfCardsAsList { public Bag<Suit> countsBySuit() { return null; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); ImmutableList<Set<Card>> dealHands(
MutableStack<Card> shuffled,
int hands,
int cardsPerHand); ImmutableList<Card> diamonds(); ImmutableList<Card> hearts(); ImmutableList<Card> spades(); ImmutableList<Card> clubs(); Bag<Suit> countsBySuit(); Bag<Rank> countsByRank(); ImmutableList<Card> getCards(); ImmutableListMultimap<Suit, Card> getCardsBySuit(); }
|
EclipseCollectionsDeckOfCardsAsList { public Bag<Suit> countsBySuit() { return null; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); ImmutableList<Set<Card>> dealHands(
MutableStack<Card> shuffled,
int hands,
int cardsPerHand); ImmutableList<Card> diamonds(); ImmutableList<Card> hearts(); ImmutableList<Card> spades(); ImmutableList<Card> clubs(); Bag<Suit> countsBySuit(); Bag<Rank> countsByRank(); ImmutableList<Card> getCards(); ImmutableListMultimap<Suit, Card> getCardsBySuit(); }
|
@Test public void remove() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.remove("A")); }
|
@Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void remove_keyValue() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.remove("A")); }
|
@Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void containsKey() { Assert.assertTrue(this.testObj.containsKey("A")); Assert.assertTrue(this.testObj.containsKey("B")); Assert.assertFalse(this.testObj.containsKey("C")); }
|
@Override public boolean containsKey(Object key) { return this.BACKING_MULTIMAP.containsKey(key); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsKey(Object key) { return this.BACKING_MULTIMAP.containsKey(key); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsKey(Object key) { return this.BACKING_MULTIMAP.containsKey(key); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsKey(Object key) { return this.BACKING_MULTIMAP.containsKey(key); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsKey(Object key) { return this.BACKING_MULTIMAP.containsKey(key); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void containsValue() { Assert.assertTrue(this.testObj.containsValue(1)); Assert.assertTrue(this.testObj.containsValue(2)); Assert.assertTrue(this.testObj.containsValue(3)); Assert.assertTrue(this.testObj.containsValue(10)); Assert.assertFalse(this.testObj.containsValue(4)); }
|
@Override public boolean containsValue(Object value) { return this.BACKING_MULTIMAP.containsValue(value); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsValue(Object value) { return this.BACKING_MULTIMAP.containsValue(value); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsValue(Object value) { return this.BACKING_MULTIMAP.containsValue(value); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsValue(Object value) { return this.BACKING_MULTIMAP.containsValue(value); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsValue(Object value) { return this.BACKING_MULTIMAP.containsValue(value); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void clear() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.clear()); }
|
@Override public void clear() { throw new UnsupportedOperationException("Not allowed to perform clear() on " + UnmodifiableArrayListMultimap.class); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void clear() { throw new UnsupportedOperationException("Not allowed to perform clear() on " + UnmodifiableArrayListMultimap.class); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void clear() { throw new UnsupportedOperationException("Not allowed to perform clear() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void clear() { throw new UnsupportedOperationException("Not allowed to perform clear() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void clear() { throw new UnsupportedOperationException("Not allowed to perform clear() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void keySet() { Assert.assertEquals(MutableSet.of("A", "B"), this.testObj.keySet()); }
|
@Override public Set<K> keySet() { return this.BACKING_MULTIMAP.keySet(); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public Set<K> keySet() { return this.BACKING_MULTIMAP.keySet(); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public Set<K> keySet() { return this.BACKING_MULTIMAP.keySet(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public Set<K> keySet() { return this.BACKING_MULTIMAP.keySet(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public Set<K> keySet() { return this.BACKING_MULTIMAP.keySet(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void forEach() { MutableList<String> combined = MutableList.empty(); this.testObj.forEach((key, value) -> combined.add(key + value.toString())); Assert.assertEquals( MutableList.of("A1", "A2", "A3", "A1", "B10", "B10"), combined); }
|
@Override public void forEach(BiConsumer<K, V> biConsumer) { this.BACKING_MULTIMAP.forEach(biConsumer); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void forEach(BiConsumer<K, V> biConsumer) { this.BACKING_MULTIMAP.forEach(biConsumer); } }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void forEach(BiConsumer<K, V> biConsumer) { this.BACKING_MULTIMAP.forEach(biConsumer); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void forEach(BiConsumer<K, V> biConsumer) { this.BACKING_MULTIMAP.forEach(biConsumer); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void forEach(BiConsumer<K, V> biConsumer) { this.BACKING_MULTIMAP.forEach(biConsumer); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override Set<K> keySet(); @Override MutableList<V> get(Object key); @Override void forEach(BiConsumer<K, V> biConsumer); @Override boolean put(K key, RichIterable<V> value); @Override boolean put(K key, V value); @Override MutableList<V> remove(Object key); @Override boolean remove(K key, V value); @Override void putAll(Map<? extends K, ? extends RichIterable<V>> map); @Override int hashCode(); @Override boolean equals(Object obj); }
|
@Test public void get_put() { this.testObj.put("A", 1); Assert.assertEquals(MutableList.of(1), this.testObj.get("A")); Assert.assertEquals(1, this.testObj.size()); this.testObj.put("A", 2); Assert.assertEquals(MutableList.of(1, 2), this.testObj.get("A")); Assert.assertEquals(2, this.testObj.size()); this.testObj.put("A", 1); Assert.assertEquals(MutableList.of(1, 2, 1), this.testObj.get("A")); Assert.assertEquals(3, this.testObj.size()); this.testObj.put("B", 10); Assert.assertEquals(MutableList.of(10), this.testObj.get("B")); Assert.assertEquals(4, this.testObj.size()); this.testObj.put("B", 11); Assert.assertEquals(MutableList.of(10, 11), this.testObj.get("B")); Assert.assertEquals(5, this.testObj.size()); this.testObj.put("A", 2); Assert.assertEquals(MutableList.of(1, 2, 1, 2), this.testObj.get("A")); Assert.assertEquals(6, this.testObj.size()); }
|
@Override public int size() { return this.size; }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
@Test public void get_putIterable() { this.testObj.put("A", MutableList.of(1)); Assert.assertEquals(MutableList.of(1), this.testObj.get("A")); Assert.assertEquals(1, this.testObj.size()); this.testObj.put("A", MutableList.of(2, 1)); Assert.assertEquals(MutableList.of(1, 2, 1), this.testObj.get("A")); Assert.assertEquals(3, this.testObj.size()); this.testObj.put("B", MutableList.of(10, 11)); Assert.assertEquals(MutableList.of(10, 11), this.testObj.get("B")); Assert.assertEquals(5, this.testObj.size()); this.testObj.put("A", MutableList.of(2, 3, 4)); Assert.assertEquals(MutableList.of(1, 2, 1, 2, 3, 4), this.testObj.get("A")); Assert.assertEquals(8, this.testObj.size()); }
|
@Override public int size() { return this.size; }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
@Test public void putAll() { this.testObj.putAll(MutableMap.of("A", MutableList.of(1, 2, 3))); Assert.assertEquals(MutableList.of(1, 2, 3), this.testObj.get("A")); Assert.assertEquals(3, this.testObj.size()); this.testObj.putAll(MutableMap.of("B", MutableList.of(10, 10))); Assert.assertEquals(MutableList.of(10, 10), this.testObj.get("B")); Assert.assertEquals(5, this.testObj.size()); }
|
@Override public int size() { return this.size; }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
@Test public void countsByRank() { Assert.assertEquals( this.jdkDeck.countsByRank().get(Rank.TEN).intValue(), this.ecDeck.countsByRank().occurrencesOf(Rank.SEVEN)); }
|
public Bag<Rank> countsByRank() { return null; }
|
EclipseCollectionsDeckOfCardsAsList { public Bag<Rank> countsByRank() { return null; } }
|
EclipseCollectionsDeckOfCardsAsList { public Bag<Rank> countsByRank() { return null; } EclipseCollectionsDeckOfCardsAsList(); }
|
EclipseCollectionsDeckOfCardsAsList { public Bag<Rank> countsByRank() { return null; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); ImmutableList<Set<Card>> dealHands(
MutableStack<Card> shuffled,
int hands,
int cardsPerHand); ImmutableList<Card> diamonds(); ImmutableList<Card> hearts(); ImmutableList<Card> spades(); ImmutableList<Card> clubs(); Bag<Suit> countsBySuit(); Bag<Rank> countsByRank(); ImmutableList<Card> getCards(); ImmutableListMultimap<Suit, Card> getCardsBySuit(); }
|
EclipseCollectionsDeckOfCardsAsList { public Bag<Rank> countsByRank() { return null; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); ImmutableList<Set<Card>> dealHands(
MutableStack<Card> shuffled,
int hands,
int cardsPerHand); ImmutableList<Card> diamonds(); ImmutableList<Card> hearts(); ImmutableList<Card> spades(); ImmutableList<Card> clubs(); Bag<Suit> countsBySuit(); Bag<Rank> countsByRank(); ImmutableList<Card> getCards(); ImmutableListMultimap<Suit, Card> getCardsBySuit(); }
|
@Test public void remove() { Assert.assertEquals(MutableList.empty(), this.testObj.remove("A")); this.testObj.putAll(MutableMap.of("A", MutableList.of(1, 2, 3))); this.testObj.putAll(MutableMap.of("B", MutableList.of(10, 10))); Assert.assertEquals(5, this.testObj.size()); this.testObj.remove("A"); Assert.assertEquals(2, this.testObj.size()); this.testObj.remove("B"); Assert.assertEquals(0, this.testObj.size()); }
|
@Override public int size() { return this.size; }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
@Test public void remove_keyValue() { Assert.assertEquals(MutableList.empty(), this.testObj.remove("A")); this.testObj.putAll(MutableMap.of("A", MutableList.of(1, 2, 3, 1))); this.testObj.putAll(MutableMap.of("B", MutableList.of(10, 10))); Assert.assertEquals(6, this.testObj.size()); this.testObj.remove("A", 1); Assert.assertEquals(MutableList.of(2, 3, 1), this.testObj.get("A")); Assert.assertEquals(5, this.testObj.size()); this.testObj.remove("B", 10); MutableList<Integer> getForB = this.testObj.get("B"); Assert.assertEquals(MutableList.of(10), getForB); Assert.assertEquals(4, this.testObj.size()); this.testObj.remove("B", 10); Assert.assertEquals(MutableList.empty(), getForB); Assert.assertEquals(3, this.testObj.size()); Assert.assertNotSame(getForB, this.testObj.get("B")); }
|
@Override public int size() { return this.size; }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
@Test public void clear() { Assert.assertEquals(0, this.testObj.size()); this.testObj.clear(); this.testObj.putAll(MutableMap.of("A", MutableList.of(1, 2, 3, 1))); this.testObj.putAll(MutableMap.of("B", MutableList.of(10, 10))); Assert.assertEquals(6, this.testObj.size()); this.testObj.clear(); Assert.assertEquals(0, this.testObj.size()); }
|
@Override public int size() { return this.size; }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
@Test public void hashCodeEquals() { this.testObj.putAll(MutableMap.of("A", MutableList.of(1, 2, 3, 1))); this.testObj.putAll(MutableMap.of("B", MutableList.of(10, 10))); ArrayListMultimap<String, Integer> other = ArrayListMultimap.newMultimap(); other.putAll(MutableMap.of("A", MutableList.of(1, 2, 3, 1))); Assert.assertTrue(this.testObj.equals(this.testObj)); Assert.assertFalse(this.testObj.equals(other)); Assert.assertFalse(other.equals(this.testObj)); other.putAll(MutableMap.of("B", MutableList.of(10, 10))); Verify.assertEqualsAndHashCode(this.testObj, this.testObj); Verify.assertEqualsAndHashCode(this.testObj, other); Verify.assertEqualsAndHashCode(other, this.testObj); }
|
public static <K, V> ArrayListMultimap<K, V> newMultimap() { return new ArrayListMultimap<>(); }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { public static <K, V> ArrayListMultimap<K, V> newMultimap() { return new ArrayListMultimap<>(); } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { public static <K, V> ArrayListMultimap<K, V> newMultimap() { return new ArrayListMultimap<>(); } }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { public static <K, V> ArrayListMultimap<K, V> newMultimap() { return new ArrayListMultimap<>(); } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { public static <K, V> ArrayListMultimap<K, V> newMultimap() { return new ArrayListMultimap<>(); } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
|
@Test public void allCards() { Assert.assertEquals(this.jdk1Deck.getCards(), this.jdk2Deck.getCards()); }
|
public SortedSet<Card> getCards() { return this.cards; }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } JDK8DeckOfCardsAsSortedSet(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
@Test public void cardsAreImmutable() { var jdk2Cards = this.jdk2Deck.getCards(); Verify.assertThrows( UnsupportedOperationException.class, () -> jdk2Cards.remove(null)); Verify.assertThrows( UnsupportedOperationException.class, jdk2Cards::clear); Verify.assertThrows( UnsupportedOperationException.class, () -> jdk2Cards.add(null)); }
|
public SortedSet<Card> getCards() { return this.cards; }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } JDK8DeckOfCardsAsSortedSet(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
@Test public void diamonds() { Assert.assertEquals(this.jdk1Deck.diamonds(), this.jdk2Deck.diamonds()); }
|
public SortedSet<Card> diamonds() { return null; }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> diamonds() { return null; } }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> diamonds() { return null; } JDK8DeckOfCardsAsSortedSet(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> diamonds() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> diamonds() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
@Test public void hearts() { Assert.assertEquals(this.jdk1Deck.hearts(), this.jdk2Deck.hearts()); }
|
public SortedSet<Card> hearts() { return null; }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> hearts() { return null; } }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> hearts() { return null; } JDK8DeckOfCardsAsSortedSet(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> hearts() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> hearts() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
@Test public void spades() { Assert.assertEquals(this.jdk1Deck.spades(), this.jdk2Deck.spades()); }
|
public SortedSet<Card> spades() { return null; }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> spades() { return null; } }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> spades() { return null; } JDK8DeckOfCardsAsSortedSet(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> spades() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> spades() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
@Test public void clubs() { Assert.assertEquals(this.jdk1Deck.clubs(), this.jdk2Deck.clubs()); }
|
public SortedSet<Card> clubs() { return null; }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> clubs() { return null; } }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> clubs() { return null; } JDK8DeckOfCardsAsSortedSet(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> clubs() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> clubs() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(
Deque<Card> shuffled,
int hands,
int cardsPerHand); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.