Skip to content

Commit

Permalink
Merge pull request #583 from carl-mastrangelo/removeallguava
Browse files Browse the repository at this point in the history
Remove last remaining usages of guava
  • Loading branch information
carl-mastrangelo authored Dec 4, 2019
2 parents 1b5203e + c602283 commit e4ffaa7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
4 changes: 0 additions & 4 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ Validation framework developed by JBoss
https://github.com/hibernate/hibernate-validator
Copyright (c) 2009 Red Hat, Inc. and/or its affiliates, and individual contributors

Alternative collection types provided by Google Guava from
http://code.google.com/p/guava-libraries/
Copyright (C) 2007 Google Inc.

Google Guice
https://code.google.com/p/google-guice/
Copyright (C) 2006 Google Inc.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.netflix.archaius.bridge;

import java.util.ArrayList;
import java.util.HashSet;
import org.apache.commons.configuration.AbstractConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.HierarchicalConfiguration;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.netflix.archaius.api.Config;
import com.netflix.archaius.api.ConfigListener;
import com.netflix.archaius.api.config.CompositeConfig;
Expand Down Expand Up @@ -129,12 +129,12 @@ public void addConfiguration(AbstractConfiguration config, String name) {

@Override
public Set<String> getConfigurationNames() {
return Sets.newHashSet(libraries.getConfigNames());
return new HashSet<>(libraries.getConfigNames());
}

@Override
public List<String> getConfigurationNameList() {
return Lists.newArrayList(libraries.getConfigNames());
return new ArrayList<>(libraries.getConfigNames());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
*/
package com.netflix.archaius.config;

import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Properties;

import java.util.Set;
import org.junit.Assert;
import org.junit.Test;

import com.google.common.collect.Sets;
import com.netflix.archaius.DefaultConfigLoader;
import com.netflix.archaius.cascade.ConcatCascadeStrategy;
import com.netflix.archaius.api.exceptions.ConfigException;
Expand Down Expand Up @@ -129,19 +132,27 @@ public void getKeysTest() throws ConfigException {
composite.addConfig("b", MapConfig.builder().put("b1", "A").put("b2", "B").build());

iter = composite.getKeys();
Assert.assertEquals(Sets.newHashSet("b1", "b2"), Sets.newHashSet(iter));
Assert.assertEquals(set("b1", "b2"), set(iter));

composite.addConfig("c", EmptyConfig.INSTANCE);

iter = composite.getKeys();
Assert.assertEquals(Sets.newHashSet("b1", "b2"), Sets.newHashSet(iter));
Assert.assertEquals(set("b1", "b2"), set(iter));

composite.addConfig("d", MapConfig.builder().put("d1", "A").put("d2", "B").build());
composite.addConfig("e", MapConfig.builder().put("e1", "A").put("e2", "B").build());

iter = composite.getKeys();
Assert.assertEquals(Sets.newHashSet("b1", "b2", "d1", "d2", "e1", "e2"), Sets.newHashSet(iter));


Assert.assertEquals(set("b1", "b2", "d1", "d2", "e1", "e2"), set(iter));
}

private static Set<String> set(String ... values) {
return Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(values)));
}

private static Set<String> set(Iterator<String> values) {
Set<String> vals = new LinkedHashSet<>();
values.forEachRemaining(e -> vals.add(e));
return Collections.unmodifiableSet(vals);
}
}
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ subprojects {
testCompile 'junit:junit:4.11'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'org.mockito:mockito-core:1.+'
testCompile 'com.google.guava:guava:18.0'
}

group = "com.netflix.${githubProjectName}"
Expand Down

0 comments on commit e4ffaa7

Please sign in to comment.