Apply "type inference for generic instance creation" Java 7 feature
Change-Id: Ia14802c903ca67b9d94dc6038d70b0e9644bc621
This commit is contained in:
@@ -130,8 +130,7 @@ public class AcceptanceTestRequestScope {
|
||||
}
|
||||
}
|
||||
|
||||
private static final ThreadLocal<Context> current =
|
||||
new ThreadLocal<Context>();
|
||||
private static final ThreadLocal<Context> current = new ThreadLocal<>();
|
||||
|
||||
private static Context requireContext() {
|
||||
final Context ctx = current.get();
|
||||
|
@@ -212,6 +212,6 @@ class H2CacheFactory implements PersistentCacheFactory, LifecycleListener {
|
||||
long maxSize) {
|
||||
File db = new File(cacheDir, name).getAbsoluteFile();
|
||||
String url = "jdbc:h2:" + db.toURI().toString();
|
||||
return new SqlStore<K, V>(url, keyType, maxSize);
|
||||
return new SqlStore<>(url, keyType, maxSize);
|
||||
}
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
|
||||
@Override
|
||||
public void put(final K key, V val) {
|
||||
final ValueHolder<V> h = new ValueHolder<V>(val);
|
||||
final ValueHolder<V> h = new ValueHolder<>(val);
|
||||
h.created = TimeUtil.nowMs();
|
||||
mem.put(key, h);
|
||||
executor.execute(new Runnable() {
|
||||
@@ -246,7 +246,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
final ValueHolder<V> h = new ValueHolder<V>(loader.load(key));
|
||||
final ValueHolder<V> h = new ValueHolder<>(loader.load(key));
|
||||
h.created = TimeUtil.nowMs();
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
@@ -302,7 +302,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
return (KeyType<K>) OTHER;
|
||||
}
|
||||
|
||||
static final KeyType<?> OTHER = new KeyType<Object>();
|
||||
static final KeyType<?> OTHER = new KeyType<>();
|
||||
static final KeyType<String> STRING = new KeyType<String>() {
|
||||
@Override
|
||||
String columnType() {
|
||||
@@ -346,7 +346,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
|
||||
int cores = Runtime.getRuntime().availableProcessors();
|
||||
int keep = Math.min(cores, 16);
|
||||
this.handles = new ArrayBlockingQueue<SqlHandle>(keep);
|
||||
this.handles = new ArrayBlockingQueue<>(keep);
|
||||
}
|
||||
|
||||
synchronized void open() {
|
||||
@@ -440,7 +440,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
V val = (V) r.getObject(1);
|
||||
ValueHolder<V> h = new ValueHolder<V>(val);
|
||||
ValueHolder<V> h = new ValueHolder<>(val);
|
||||
h.clean = true;
|
||||
hitCount.incrementAndGet();
|
||||
touch(c, key);
|
||||
|
@@ -33,7 +33,7 @@ public class LabelTypes {
|
||||
|
||||
public LabelTypes(final List<? extends LabelType> approvals) {
|
||||
labelTypes =
|
||||
Collections.unmodifiableList(new ArrayList<LabelType>(approvals));
|
||||
Collections.unmodifiableList(new ArrayList<>(approvals));
|
||||
}
|
||||
|
||||
public List<LabelType> getLabelTypes() {
|
||||
|
@@ -48,7 +48,7 @@ public class Permission implements Comparable<Permission> {
|
||||
private static final int labelAsIndex;
|
||||
|
||||
static {
|
||||
NAMES_LC = new ArrayList<String>();
|
||||
NAMES_LC = new ArrayList<>();
|
||||
NAMES_LC.add(OWNER.toLowerCase());
|
||||
NAMES_LC.add(READ.toLowerCase());
|
||||
NAMES_LC.add(ABANDON.toLowerCase());
|
||||
@@ -229,7 +229,7 @@ public class Permission implements Comparable<Permission> {
|
||||
|
||||
private void initRules() {
|
||||
if (rules == null) {
|
||||
rules = new ArrayList<PermissionRule>(4);
|
||||
rules = new ArrayList<>(4);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -97,7 +97,7 @@ public class ReviewInput {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (labels == null) {
|
||||
labels = new LinkedHashMap<String, Short>(4);
|
||||
labels = new LinkedHashMap<>(4);
|
||||
}
|
||||
labels.put(name, value);
|
||||
return this;
|
||||
|
@@ -78,7 +78,7 @@ public class DynamicItem<T> {
|
||||
Key<DynamicItem<T>> key = (Key<DynamicItem<T>>) Key.get(
|
||||
Types.newParameterizedType(DynamicItem.class, member.getType()));
|
||||
binder.bind(key)
|
||||
.toProvider(new DynamicItemProvider<T>(member, key))
|
||||
.toProvider(new DynamicItemProvider<>(member, key))
|
||||
.in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
@@ -111,10 +111,10 @@ public class DynamicItem<T> {
|
||||
DynamicItem(Key<DynamicItem<T>> key, Provider<T> provider, String pluginName) {
|
||||
NamedProvider<T> in = null;
|
||||
if (provider != null) {
|
||||
in = new NamedProvider<T>(provider, pluginName);
|
||||
in = new NamedProvider<>(provider, pluginName);
|
||||
}
|
||||
this.key = key;
|
||||
this.ref = new AtomicReference<NamedProvider<T>>(in);
|
||||
this.ref = new AtomicReference<>(in);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +148,7 @@ public class DynamicItem<T> {
|
||||
* @return handle to remove the item at a later point in time.
|
||||
*/
|
||||
public RegistrationHandle set(Provider<T> impl, String pluginName) {
|
||||
final NamedProvider<T> item = new NamedProvider<T>(impl, pluginName);
|
||||
final NamedProvider<T> item = new NamedProvider<>(impl, pluginName);
|
||||
NamedProvider<T> old = null;
|
||||
while (!ref.compareAndSet(old, item)) {
|
||||
old = ref.get();
|
||||
@@ -180,7 +180,7 @@ public class DynamicItem<T> {
|
||||
*/
|
||||
public ReloadableRegistrationHandle<T> set(Key<T> key, Provider<T> impl,
|
||||
String pluginName) {
|
||||
final NamedProvider<T> item = new NamedProvider<T>(impl, pluginName);
|
||||
final NamedProvider<T> item = new NamedProvider<>(impl, pluginName);
|
||||
NamedProvider<T> old = null;
|
||||
while (!ref.compareAndSet(old, item)) {
|
||||
old = ref.get();
|
||||
@@ -216,7 +216,7 @@ public class DynamicItem<T> {
|
||||
|
||||
@Override
|
||||
public ReloadableHandle replace(Key<T> newKey, Provider<T> newItem) {
|
||||
NamedProvider<T> n = new NamedProvider<T>(newItem, item.pluginName);
|
||||
NamedProvider<T> n = new NamedProvider<>(newItem, item.pluginName);
|
||||
if (ref.compareAndSet(item, n)) {
|
||||
return new ReloadableHandle(newKey, n, defaultItem);
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ class DynamicItemProvider<T> implements Provider<DynamicItem<T>> {
|
||||
}
|
||||
|
||||
public DynamicItem<T> get() {
|
||||
return new DynamicItem<T>(key, find(injector, type), "gerrit");
|
||||
return new DynamicItem<>(key, find(injector, type), "gerrit");
|
||||
}
|
||||
|
||||
private static <T> Provider<T> find(Injector src, TypeLiteral<T> type) {
|
||||
|
@@ -81,14 +81,14 @@ public abstract class DynamicMap<T> implements Iterable<DynamicMap.Entry<T>> {
|
||||
Key<DynamicMap<T>> key = (Key<DynamicMap<T>>) Key.get(
|
||||
Types.newParameterizedType(DynamicMap.class, member.getType()));
|
||||
binder.bind(key)
|
||||
.toProvider(new DynamicMapProvider<T>(member))
|
||||
.toProvider(new DynamicMapProvider<>(member))
|
||||
.in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
final ConcurrentMap<NamePair, Provider<T>> items;
|
||||
|
||||
DynamicMap() {
|
||||
items = new ConcurrentHashMap<NamePair, Provider<T>>(
|
||||
items = new ConcurrentHashMap<>(
|
||||
16 /* initial size */,
|
||||
0.75f /* load factor */,
|
||||
1 /* concurrency level of 1, load/unload is single threaded */);
|
||||
@@ -115,7 +115,7 @@ public abstract class DynamicMap<T> implements Iterable<DynamicMap.Entry<T>> {
|
||||
* @return sorted set of active plugins that supply at least one item.
|
||||
*/
|
||||
public SortedSet<String> plugins() {
|
||||
SortedSet<String> r = new TreeSet<String>();
|
||||
SortedSet<String> r = new TreeSet<>();
|
||||
for (NamePair p : items.keySet()) {
|
||||
r.add(p.pluginName);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public abstract class DynamicMap<T> implements Iterable<DynamicMap.Entry<T>> {
|
||||
* @return items exported by a plugin, keyed by the export name.
|
||||
*/
|
||||
public SortedMap<String, Provider<T>> byPlugin(String pluginName) {
|
||||
SortedMap<String, Provider<T>> r = new TreeMap<String, Provider<T>>();
|
||||
SortedMap<String, Provider<T>> r = new TreeMap<>();
|
||||
for (Map.Entry<NamePair, Provider<T>> e : items.entrySet()) {
|
||||
if (e.getKey().pluginName.equals(pluginName)) {
|
||||
r.put(e.getKey().exportName, e.getValue());
|
||||
|
@@ -34,7 +34,7 @@ class DynamicMapProvider<T> implements Provider<DynamicMap<T>> {
|
||||
|
||||
public DynamicMap<T> get() {
|
||||
PrivateInternals_DynamicMapImpl<T> m =
|
||||
new PrivateInternals_DynamicMapImpl<T>();
|
||||
new PrivateInternals_DynamicMapImpl<>();
|
||||
List<Binding<T>> bindings = injector.findBindingsByType(type);
|
||||
if (bindings != null) {
|
||||
for (Binding<T> b : bindings) {
|
||||
|
@@ -72,7 +72,7 @@ public class DynamicSet<T> implements Iterable<T> {
|
||||
Key<DynamicSet<T>> key = (Key<DynamicSet<T>>) Key.get(
|
||||
Types.newParameterizedType(DynamicSet.class, member.getType()));
|
||||
binder.bind(key)
|
||||
.toProvider(new DynamicSetProvider<T>(member))
|
||||
.toProvider(new DynamicSetProvider<>(member))
|
||||
.in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public class DynamicSet<T> implements Iterable<T> {
|
||||
private final CopyOnWriteArrayList<AtomicReference<Provider<T>>> items;
|
||||
|
||||
DynamicSet(Collection<AtomicReference<Provider<T>>> base) {
|
||||
items = new CopyOnWriteArrayList<AtomicReference<Provider<T>>>(base);
|
||||
items = new CopyOnWriteArrayList<>(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,8 +194,7 @@ public class DynamicSet<T> implements Iterable<T> {
|
||||
* @return handle to remove the item at a later point in time.
|
||||
*/
|
||||
public RegistrationHandle add(final Provider<T> item) {
|
||||
final AtomicReference<Provider<T>> ref =
|
||||
new AtomicReference<Provider<T>>(item);
|
||||
final AtomicReference<Provider<T>> ref = new AtomicReference<>(item);
|
||||
items.add(ref);
|
||||
return new RegistrationHandle() {
|
||||
@Override
|
||||
@@ -218,7 +217,7 @@ public class DynamicSet<T> implements Iterable<T> {
|
||||
* without it ever leaving the collection.
|
||||
*/
|
||||
public ReloadableRegistrationHandle<T> add(Key<T> key, Provider<T> item) {
|
||||
AtomicReference<Provider<T>> ref = new AtomicReference<Provider<T>>(item);
|
||||
AtomicReference<Provider<T>> ref = new AtomicReference<>(item);
|
||||
items.add(ref);
|
||||
return new ReloadableHandle(ref, key, item);
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ class DynamicSetProvider<T> implements Provider<DynamicSet<T>> {
|
||||
}
|
||||
|
||||
public DynamicSet<T> get() {
|
||||
return new DynamicSet<T>(find(injector, type));
|
||||
return new DynamicSet<>(find(injector, type));
|
||||
}
|
||||
|
||||
private static <T> List<AtomicReference<Provider<T>>> find(
|
||||
@@ -47,16 +47,12 @@ class DynamicSetProvider<T> implements Provider<DynamicSet<T>> {
|
||||
if (cnt == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<AtomicReference<Provider<T>>> r = newList(cnt);
|
||||
List<AtomicReference<Provider<T>>> r = new ArrayList<>(cnt);
|
||||
for (Binding<T> b : bindings) {
|
||||
if (b.getKey().getAnnotation() != null) {
|
||||
r.add(new AtomicReference<Provider<T>>(b.getProvider()));
|
||||
r.add(new AtomicReference<>(b.getProvider()));
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private static <T> List<AtomicReference<Provider<T>>> newList(int cnt) {
|
||||
return new ArrayList<AtomicReference<Provider<T>>>(cnt);
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ import java.util.Map;
|
||||
/** <b>DO NOT USE</b> */
|
||||
public class PrivateInternals_DynamicTypes {
|
||||
public static Map<TypeLiteral<?>, DynamicItem<?>> dynamicItemsOf(Injector src) {
|
||||
Map<TypeLiteral<?>, DynamicItem<?>> m = newHashMap();
|
||||
Map<TypeLiteral<?>, DynamicItem<?>> m = new HashMap<>();
|
||||
for (Map.Entry<Key<?>, Binding<?>> e : src.getBindings().entrySet()) {
|
||||
TypeLiteral<?> type = e.getKey().getTypeLiteral();
|
||||
if (type.getRawType() == DynamicItem.class) {
|
||||
@@ -47,7 +47,7 @@ public class PrivateInternals_DynamicTypes {
|
||||
}
|
||||
|
||||
public static Map<TypeLiteral<?>, DynamicSet<?>> dynamicSetsOf(Injector src) {
|
||||
Map<TypeLiteral<?>, DynamicSet<?>> m = newHashMap();
|
||||
Map<TypeLiteral<?>, DynamicSet<?>> m = new HashMap<>();
|
||||
for (Map.Entry<Key<?>, Binding<?>> e : src.getBindings().entrySet()) {
|
||||
TypeLiteral<?> type = e.getKey().getTypeLiteral();
|
||||
if (type.getRawType() == DynamicSet.class) {
|
||||
@@ -63,7 +63,7 @@ public class PrivateInternals_DynamicTypes {
|
||||
}
|
||||
|
||||
public static Map<TypeLiteral<?>, DynamicMap<?>> dynamicMapsOf(Injector src) {
|
||||
Map<TypeLiteral<?>, DynamicMap<?>> m = newHashMap();
|
||||
Map<TypeLiteral<?>, DynamicMap<?>> m = new HashMap<>();
|
||||
for (Map.Entry<Key<?>, Binding<?>> e : src.getBindings().entrySet()) {
|
||||
TypeLiteral<?> type = e.getKey().getTypeLiteral();
|
||||
if (type.getRawType() == DynamicMap.class) {
|
||||
@@ -85,7 +85,7 @@ public class PrivateInternals_DynamicTypes {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<RegistrationHandle> handles = new ArrayList<RegistrationHandle>(4);
|
||||
List<RegistrationHandle> handles = new ArrayList<>(4);
|
||||
try {
|
||||
for (Map.Entry<TypeLiteral<?>, DynamicItem<?>> e : items.entrySet()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -115,7 +115,7 @@ public class PrivateInternals_DynamicTypes {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<RegistrationHandle> handles = new ArrayList<RegistrationHandle>(4);
|
||||
List<RegistrationHandle> handles = new ArrayList<>(4);
|
||||
try {
|
||||
for (Map.Entry<TypeLiteral<?>, DynamicSet<?>> e : sets.entrySet()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -148,7 +148,7 @@ public class PrivateInternals_DynamicTypes {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<RegistrationHandle> handles = new ArrayList<RegistrationHandle>(4);
|
||||
List<RegistrationHandle> handles = new ArrayList<>(4);
|
||||
try {
|
||||
for (Map.Entry<TypeLiteral<?>, DynamicMap<?>> e : maps.entrySet()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -183,7 +183,7 @@ public class PrivateInternals_DynamicTypes {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
handles = new ArrayList<RegistrationHandle>(4);
|
||||
handles = new ArrayList<>(4);
|
||||
Injector parent = self.getParent();
|
||||
while (parent != null) {
|
||||
handles.addAll(attachSets(self, dynamicSetsOf(parent)));
|
||||
@@ -211,10 +211,6 @@ public class PrivateInternals_DynamicTypes {
|
||||
}
|
||||
}
|
||||
|
||||
private static <K,V> Map<K, V> newHashMap() {
|
||||
return new HashMap<K,V>();
|
||||
}
|
||||
|
||||
private static <T> List<Binding<T>> bindings(Injector src, TypeLiteral<T> type) {
|
||||
return src.findBindingsByType(type);
|
||||
}
|
||||
|
@@ -21,12 +21,12 @@ public abstract class Response<T> {
|
||||
|
||||
/** HTTP 200 OK: pointless wrapper for type safety. */
|
||||
public static <T> Response<T> ok(T value) {
|
||||
return new Impl<T>(200, value);
|
||||
return new Impl<>(200, value);
|
||||
}
|
||||
|
||||
/** HTTP 201 Created: typically used when a new resource is made. */
|
||||
public static <T> Response<T> created(T value) {
|
||||
return new Impl<T>(201, value);
|
||||
return new Impl<>(201, value);
|
||||
}
|
||||
|
||||
/** HTTP 204 No Content: typically used when the resource is deleted. */
|
||||
|
@@ -31,47 +31,47 @@ public abstract class RestApiModule extends AbstractModule {
|
||||
|
||||
protected <R extends RestResource>
|
||||
ReadViewBinder<R> get(TypeLiteral<RestView<R>> viewType) {
|
||||
return new ReadViewBinder<R>(view(viewType, GET, "/"));
|
||||
return new ReadViewBinder<>(view(viewType, GET, "/"));
|
||||
}
|
||||
|
||||
protected <R extends RestResource>
|
||||
ModifyViewBinder<R> put(TypeLiteral<RestView<R>> viewType) {
|
||||
return new ModifyViewBinder<R>(view(viewType, PUT, "/"));
|
||||
return new ModifyViewBinder<>(view(viewType, PUT, "/"));
|
||||
}
|
||||
|
||||
protected <R extends RestResource>
|
||||
ModifyViewBinder<R> post(TypeLiteral<RestView<R>> viewType) {
|
||||
return new ModifyViewBinder<R>(view(viewType, POST, "/"));
|
||||
return new ModifyViewBinder<>(view(viewType, POST, "/"));
|
||||
}
|
||||
|
||||
protected <R extends RestResource>
|
||||
ModifyViewBinder<R> delete(TypeLiteral<RestView<R>> viewType) {
|
||||
return new ModifyViewBinder<R>(view(viewType, DELETE, "/"));
|
||||
return new ModifyViewBinder<>(view(viewType, DELETE, "/"));
|
||||
}
|
||||
|
||||
protected <R extends RestResource>
|
||||
ReadViewBinder<R> get(TypeLiteral<RestView<R>> viewType, String name) {
|
||||
return new ReadViewBinder<R>(view(viewType, GET, name));
|
||||
return new ReadViewBinder<>(view(viewType, GET, name));
|
||||
}
|
||||
|
||||
protected <R extends RestResource>
|
||||
ModifyViewBinder<R> put(TypeLiteral<RestView<R>> viewType, String name) {
|
||||
return new ModifyViewBinder<R>(view(viewType, PUT, name));
|
||||
return new ModifyViewBinder<>(view(viewType, PUT, name));
|
||||
}
|
||||
|
||||
protected <R extends RestResource>
|
||||
ModifyViewBinder<R> post(TypeLiteral<RestView<R>> viewType, String name) {
|
||||
return new ModifyViewBinder<R>(view(viewType, POST, name));
|
||||
return new ModifyViewBinder<>(view(viewType, POST, name));
|
||||
}
|
||||
|
||||
protected <R extends RestResource>
|
||||
ModifyViewBinder<R> delete(TypeLiteral<RestView<R>> viewType, String name) {
|
||||
return new ModifyViewBinder<R>(view(viewType, DELETE, name));
|
||||
return new ModifyViewBinder<>(view(viewType, DELETE, name));
|
||||
}
|
||||
|
||||
protected <P extends RestResource>
|
||||
ChildCollectionBinder<P> child(TypeLiteral<RestView<P>> type, String name) {
|
||||
return new ChildCollectionBinder<P>(view(type, GET, name));
|
||||
return new ChildCollectionBinder<>(view(type, GET, name));
|
||||
}
|
||||
|
||||
protected <R extends RestResource>
|
||||
|
@@ -44,8 +44,7 @@ public class CssLinker extends AbstractLinker {
|
||||
final ArtifactSet returnTo = new ArtifactSet();
|
||||
int index = 0;
|
||||
|
||||
final HashMap<String, PublicResource> css =
|
||||
new HashMap<String, PublicResource>();
|
||||
final HashMap<String, PublicResource> css = new HashMap<>();
|
||||
|
||||
for (final StandardStylesheetReference ssr : artifacts
|
||||
.<StandardStylesheetReference> find(StandardStylesheetReference.class)) {
|
||||
|
@@ -35,7 +35,7 @@ public class KeyCommandSet implements KeyPressHandler {
|
||||
}
|
||||
|
||||
public KeyCommandSet(final String setName) {
|
||||
map = new HashMap<Integer, KeyCommand>();
|
||||
map = new HashMap<>();
|
||||
name = setName;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class KeyCommandSet implements KeyPressHandler {
|
||||
|
||||
public void add(final KeyCommandSet set) {
|
||||
if (sets == null) {
|
||||
sets = new ArrayList<KeyCommandSet>();
|
||||
sets = new ArrayList<>();
|
||||
}
|
||||
assert !sets.contains(set);
|
||||
sets.add(set);
|
||||
|
@@ -133,8 +133,7 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
|
||||
* the same name, so that each set name appears at most once.
|
||||
*/
|
||||
private static Collection<KeyCommandSet> combinedSetsByName() {
|
||||
final LinkedHashMap<String, KeyCommandSet> byName =
|
||||
new LinkedHashMap<String, KeyCommandSet>();
|
||||
LinkedHashMap<String, KeyCommandSet> byName = new LinkedHashMap<>();
|
||||
for (final KeyCommandSet set : GlobalKey.active.all.getSets()) {
|
||||
KeyCommandSet v = byName.get(set.getName());
|
||||
if (v == null) {
|
||||
@@ -171,7 +170,7 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
|
||||
lists.resizeRows(row + keys.size());
|
||||
}
|
||||
|
||||
Map<KeyCommand, Integer> rows = new HashMap<KeyCommand, Integer>();
|
||||
Map<KeyCommand, Integer> rows = new HashMap<>();
|
||||
FORMAT_KEYS: for (int i = 0; i < keys.size(); i++) {
|
||||
final KeyCommand k = keys.get(i);
|
||||
if (rows.containsKey(k)) {
|
||||
@@ -234,7 +233,7 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
|
||||
}
|
||||
|
||||
private List<KeyCommand> sort(final KeyCommandSet set) {
|
||||
final List<KeyCommand> keys = new ArrayList<KeyCommand>(set.getKeys());
|
||||
final List<KeyCommand> keys = new ArrayList<>(set.getKeys());
|
||||
Collections.sort(keys, new Comparator<KeyCommand>() {
|
||||
@Override
|
||||
public int compare(KeyCommand arg0, KeyCommand arg1) {
|
||||
|
@@ -23,7 +23,7 @@ class AttMap {
|
||||
private static final HashMap<String, Tag> TAGS;
|
||||
static {
|
||||
final Tag src = new SrcTag();
|
||||
TAGS = new HashMap<String, Tag>();
|
||||
TAGS = new HashMap<>();
|
||||
TAGS.put("a", new AnchorTag());
|
||||
TAGS.put("form", new FormTag());
|
||||
TAGS.put("img", src);
|
||||
@@ -31,8 +31,8 @@ class AttMap {
|
||||
TAGS.put("frame", src);
|
||||
}
|
||||
|
||||
private final ArrayList<String> names = new ArrayList<String>();
|
||||
private final ArrayList<String> values = new ArrayList<String>();
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<String> values = new ArrayList<>();
|
||||
|
||||
private Tag tag = ANY;
|
||||
private int live;
|
||||
|
@@ -45,7 +45,7 @@ public abstract class HighlightSuggestOracle extends SuggestOracle {
|
||||
final Response response) {
|
||||
final String qpat = getQueryPattern(request.getQuery());
|
||||
final boolean html = isHTML();
|
||||
final ArrayList<Suggestion> r = new ArrayList<Suggestion>();
|
||||
final ArrayList<Suggestion> r = new ArrayList<>();
|
||||
for (final Suggestion s : response.getSuggestions()) {
|
||||
r.add(new BoldSuggestion(qpat, s, html));
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ public class DialogVisibleEvent extends GwtEvent<DialogVisibleHandler> {
|
||||
|
||||
public static Type<DialogVisibleHandler> getType() {
|
||||
if (TYPE == null) {
|
||||
TYPE = new Type<DialogVisibleHandler>();
|
||||
TYPE = new Type<>();
|
||||
}
|
||||
return TYPE;
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ class MessageOfTheDayBar extends Composite {
|
||||
}
|
||||
|
||||
private static List<HostPageData.Message> filter(List<HostPageData.Message> in) {
|
||||
List<HostPageData.Message> show = new ArrayList<HostPageData.Message>();
|
||||
List<HostPageData.Message> show = new ArrayList<>();
|
||||
for (HostPageData.Message m : in) {
|
||||
if (Cookies.getCookie(cookieName(m)) == null) {
|
||||
show.add(m);
|
||||
|
@@ -124,8 +124,8 @@ public class PermissionEditor extends Composite implements Editor<Permission>,
|
||||
|
||||
PermissionNameRenderer nameRenderer =
|
||||
new PermissionNameRenderer(projectAccess.getCapabilities());
|
||||
normalName = new ValueLabel<String>(nameRenderer);
|
||||
deletedName = new ValueLabel<String>(nameRenderer);
|
||||
normalName = new ValueLabel<>(nameRenderer);
|
||||
deletedName = new ValueLabel<>(nameRenderer);
|
||||
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
groupToAdd.setProject(projectName);
|
||||
|
@@ -101,7 +101,7 @@ public class PermissionRuleEditor extends Composite implements
|
||||
Permission permission,
|
||||
PermissionRange.WithDefaults validRange) {
|
||||
this.groupInfo = groupInfo;
|
||||
action = new ValueListBox<PermissionRule.Action>(actionRenderer);
|
||||
action = new ValueListBox<>(actionRenderer);
|
||||
|
||||
if (validRange != null && 10 < validRange.getRangeSize()) {
|
||||
min = new RangeBox.Box();
|
||||
|
@@ -49,7 +49,7 @@ abstract class RangeBox extends Composite implements
|
||||
final ValueListBox<Integer> list;
|
||||
|
||||
List() {
|
||||
list = new ValueListBox<Integer>(rangeRenderer);
|
||||
list = new ValueListBox<>(rangeRenderer);
|
||||
initWidget(list);
|
||||
}
|
||||
|
||||
|
@@ -300,7 +300,7 @@ public class ChangeScreen extends Screen
|
||||
CallbackGroup cbs1 = new CallbackGroup();
|
||||
final CallbackGroup cbs2 = new CallbackGroup();
|
||||
final PatchSet.Id psId = event.getValue().getCurrentPatchSet().getId();
|
||||
final Map<String, Patch> patches = new HashMap<String, Patch>();
|
||||
final Map<String, Patch> patches = new HashMap<>();
|
||||
String revId =
|
||||
event.getValue().getCurrentPatchSetDetail().getInfo().getRevId();
|
||||
|
||||
@@ -330,7 +330,7 @@ public class ChangeScreen extends Screen
|
||||
|
||||
private void dependsOn(RelatedChanges.RelatedInfo info) {
|
||||
ChangeAndCommit self = null;
|
||||
Map<String, ChangeAndCommit> m = new HashMap<String, ChangeAndCommit>();
|
||||
Map<String, ChangeAndCommit> m = new HashMap<>();
|
||||
for (int i = 0; i < info.changes().length(); i++) {
|
||||
ChangeAndCommit c = info.changes().get(i);
|
||||
if (changeId.equals(c.legacy_id())) {
|
||||
@@ -342,7 +342,7 @@ public class ChangeScreen extends Screen
|
||||
}
|
||||
if (self != null && self.commit() != null
|
||||
&& self.commit().parents() != null) {
|
||||
List<ChangeInfo> d = new ArrayList<ChangeInfo>();
|
||||
List<ChangeInfo> d = new ArrayList<>();
|
||||
for (CommitInfo p : Natives.asList(self.commit().parents())) {
|
||||
ChangeAndCommit pc = m.get(p.commit());
|
||||
if (pc != null && pc.has_change_number()) {
|
||||
@@ -356,12 +356,12 @@ public class ChangeScreen extends Screen
|
||||
}
|
||||
|
||||
private void neededBy(RelatedChanges.RelatedInfo info) {
|
||||
Set<String> mine = new HashSet<String>();
|
||||
Set<String> mine = new HashSet<>();
|
||||
for (PatchSet ps : event.getValue().getPatchSets()) {
|
||||
mine.add(ps.getRevision().get());
|
||||
}
|
||||
|
||||
List<ChangeInfo> n = new ArrayList<ChangeInfo>();
|
||||
List<ChangeInfo> n = new ArrayList<>();
|
||||
for (int i = 0; i < info.changes().length(); i++) {
|
||||
ChangeAndCommit c = info.changes().get(i);
|
||||
if (c.has_change_number()
|
||||
@@ -418,7 +418,7 @@ public class ChangeScreen extends Screen
|
||||
}
|
||||
public void onFailure(Throwable caught) {}
|
||||
}));
|
||||
final Set<PatchSet.Id> withDrafts = new HashSet<PatchSet.Id>();
|
||||
final Set<PatchSet.Id> withDrafts = new HashSet<>();
|
||||
event.getValue().setPatchSetsWithDraftComments(withDrafts);
|
||||
for (PatchSet ps : event.getValue().getPatchSets()) {
|
||||
if (!ps.getId().equals(psId)) {
|
||||
@@ -478,7 +478,7 @@ public class ChangeScreen extends Screen
|
||||
public void onSuccess(NativeMap<FileInfo> result) {
|
||||
JsArray<FileInfo> fileInfos = result.values();
|
||||
FileInfo.sortFileInfoByPath(fileInfos);
|
||||
List<Patch> list = new ArrayList<Patch>(fileInfos.length());
|
||||
List<Patch> list = new ArrayList<>(fileInfos.length());
|
||||
for (FileInfo f : Natives.asList(fileInfos)) {
|
||||
Patch p = patches.get(f.path());
|
||||
if (p == null) {
|
||||
|
@@ -59,7 +59,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
|
||||
keysAction.add(new StarKeyCommand(0, 's', Util.C.changeTableStar()));
|
||||
}
|
||||
|
||||
sections = new ArrayList<Section>();
|
||||
sections = new ArrayList<>();
|
||||
table.setText(0, C_STAR, "");
|
||||
table.setText(0, C_SUBJECT, Util.C.changeTableColumnSubject());
|
||||
table.setText(0, C_OWNER, Util.C.changeTableColumnOwner());
|
||||
@@ -308,7 +308,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
|
||||
parent.insertNoneRow(dataBegin);
|
||||
}
|
||||
} else {
|
||||
Set<Change.Id> cids = new HashSet<Change.Id>();
|
||||
Set<Change.Id> cids = new HashSet<>();
|
||||
|
||||
if (!hadData) {
|
||||
parent.removeRow(dataBegin);
|
||||
|
@@ -76,7 +76,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
||||
private Grid infoTable;
|
||||
private Panel actionsPanel;
|
||||
private PatchTable patchTable;
|
||||
private final Set<ClickHandler> registeredClickHandler = new HashSet<ClickHandler>();
|
||||
private final Set<ClickHandler> registeredClickHandler = new HashSet<>();
|
||||
|
||||
private PatchSet.Id diffBaseId;
|
||||
|
||||
|
@@ -44,7 +44,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class PatchSetsBlock extends Composite {
|
||||
private final Map<PatchSet.Id, PatchSetComplexDisclosurePanel> patchSetPanels =
|
||||
new HashMap<PatchSet.Id, PatchSetComplexDisclosurePanel>();
|
||||
new HashMap<>();
|
||||
|
||||
private final FlowPanel body;
|
||||
private HandlerRegistration regNavigation;
|
||||
@@ -84,7 +84,7 @@ public class PatchSetsBlock extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
patchSetPanelsList = new ArrayList<PatchSetComplexDisclosurePanel>();
|
||||
patchSetPanelsList = new ArrayList<>();
|
||||
|
||||
for (final PatchSet ps : patchSets) {
|
||||
final PatchSetComplexDisclosurePanel p =
|
||||
|
@@ -105,7 +105,7 @@ public class PatchTable extends Composite {
|
||||
|
||||
private Map<Key, Integer> patchMap() {
|
||||
if (patchMap == null) {
|
||||
patchMap = new HashMap<Patch.Key, Integer>();
|
||||
patchMap = new HashMap<>();
|
||||
for (int i = 0; i < patchList.size(); i++) {
|
||||
patchMap.put(patchList.get(i).getKey(), i);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class PatchTable extends Composite {
|
||||
myTable.addClickHandler(clickHandler);
|
||||
} else {
|
||||
if (clickHandlers == null) {
|
||||
clickHandlers = new ArrayList<ClickHandler>(2);
|
||||
clickHandlers = new ArrayList<>(2);
|
||||
}
|
||||
clickHandlers.add(clickHandler);
|
||||
}
|
||||
|
@@ -97,7 +97,7 @@ public class PublishCommentScreen extends AccountScreen implements
|
||||
super.onInitUI();
|
||||
addStyleName(Gerrit.RESOURCES.css().publishCommentsScreen());
|
||||
|
||||
approvalButtons = new ArrayList<ValueRadioButton>();
|
||||
approvalButtons = new ArrayList<>();
|
||||
descBlock = new ChangeDescriptionBlock(null);
|
||||
add(descBlock);
|
||||
|
||||
@@ -289,7 +289,7 @@ public class PublishCommentScreen extends AccountScreen implements
|
||||
if (nativeValues == null || nativeValues.length() == 0) {
|
||||
return;
|
||||
}
|
||||
List<String> values = new ArrayList<String>(nativeValues.length());
|
||||
List<String> values = new ArrayList<>(nativeValues.length());
|
||||
for (int i = 0; i < nativeValues.length(); i++) {
|
||||
values.add(nativeValues.get(i));
|
||||
}
|
||||
@@ -350,7 +350,7 @@ public class PublishCommentScreen extends AccountScreen implements
|
||||
}
|
||||
|
||||
draftsPanel.clear();
|
||||
commentEditors = new ArrayList<CommentEditorPanel>();
|
||||
commentEditors = new ArrayList<>();
|
||||
|
||||
if (!drafts.isEmpty()) {
|
||||
draftsPanel.add(new SmallHeading(Util.C.headingPatchComments()));
|
||||
@@ -468,8 +468,8 @@ public class PublishCommentScreen extends AccountScreen implements
|
||||
}
|
||||
|
||||
private List<PatchLineComment> draftList() {
|
||||
List<PatchLineComment> d = new ArrayList<PatchLineComment>();
|
||||
List<String> paths = new ArrayList<String>(drafts.keySet());
|
||||
List<PatchLineComment> d = new ArrayList<>();
|
||||
List<String> paths = new ArrayList<>(drafts.keySet());
|
||||
Collections.sort(paths);
|
||||
for (String path : paths) {
|
||||
JsArray<CommentInfo> comments = drafts.get(path);
|
||||
@@ -512,7 +512,7 @@ public class PublishCommentScreen extends AccountScreen implements
|
||||
SavedState(final PublishCommentScreen p) {
|
||||
patchSetId = p.patchSetId;
|
||||
message = p.message.getText();
|
||||
approvals = new HashMap<String, String>();
|
||||
approvals = new HashMap<>();
|
||||
for (final ValueRadioButton b : p.approvalButtons) {
|
||||
if (b.getValue()) {
|
||||
approvals.put(b.label.name(), b.value);
|
||||
|
@@ -429,8 +429,8 @@ class PreferencesBox extends Composite {
|
||||
private static final Map<String, String> NAME_TO_MODE;
|
||||
private static final Map<String, String> NORMALIZED_MODES;
|
||||
static {
|
||||
NAME_TO_MODE = new TreeMap<String, String>();
|
||||
NORMALIZED_MODES = new HashMap<String, String>();
|
||||
NAME_TO_MODE = new TreeMap<>();
|
||||
NORMALIZED_MODES = new HashMap<>();
|
||||
for (String type : ModeInjector.getKnownMimeTypes()) {
|
||||
String name = type;
|
||||
if (name.startsWith("text/x-")) {
|
||||
|
@@ -90,7 +90,7 @@ public class PatchSetSelectBox extends Composite {
|
||||
this.idSideA = idSideA;
|
||||
this.idSideB = idSideB;
|
||||
this.idActive = (side == Side.A) ? idSideA : idSideB;
|
||||
this.links = new HashMap<Integer, Anchor>();
|
||||
this.links = new HashMap<>();
|
||||
|
||||
linkPanel.clear();
|
||||
|
||||
|
@@ -327,7 +327,7 @@ public class RestApi {
|
||||
|
||||
private <T extends JavaScriptObject> void send(
|
||||
Method method, AsyncCallback<T> cb) {
|
||||
HttpCallback<T> httpCallback = new HttpCallback<T>(background, cb);
|
||||
HttpCallback<T> httpCallback = new HttpCallback<>(background, cb);
|
||||
try {
|
||||
if (!background) {
|
||||
RpcStatus.INSTANCE.onRpcStart();
|
||||
@@ -367,7 +367,7 @@ public class RestApi {
|
||||
private <T extends JavaScriptObject> void sendJSON(
|
||||
Method method, JavaScriptObject content,
|
||||
AsyncCallback<T> cb) {
|
||||
HttpCallback<T> httpCallback = new HttpCallback<T>(background, cb);
|
||||
HttpCallback<T> httpCallback = new HttpCallback<>(background, cb);
|
||||
try {
|
||||
if (!background) {
|
||||
RpcStatus.INSTANCE.onRpcStart();
|
||||
@@ -384,7 +384,7 @@ public class RestApi {
|
||||
|
||||
private <T extends JavaScriptObject> void sendRaw(Method method, String body,
|
||||
AsyncCallback<T> cb) {
|
||||
HttpCallback<T> httpCallback = new HttpCallback<T>(background, cb);
|
||||
HttpCallback<T> httpCallback = new HttpCallback<>(background, cb);
|
||||
try {
|
||||
if (!background) {
|
||||
RpcStatus.INSTANCE.onRpcStart();
|
||||
|
@@ -50,8 +50,7 @@ public abstract class CherryPickDialog extends ActionDialog {
|
||||
newBranch = new SuggestBox(new HighlightSuggestOracle() {
|
||||
@Override
|
||||
protected void onRequestSuggestions(Request request, Callback done) {
|
||||
LinkedList<BranchSuggestion> suggestions =
|
||||
new LinkedList<BranchSuggestion>();
|
||||
LinkedList<BranchSuggestion> suggestions = new LinkedList<>();
|
||||
for (final BranchInfo b : branches) {
|
||||
if (b.ref().contains(request.getQuery())) {
|
||||
suggestions.add(new BranchSuggestion(b));
|
||||
|
@@ -24,7 +24,7 @@ public class ScreenLoadEvent extends GwtEvent<ScreenLoadHandler> {
|
||||
this.screen = screen;
|
||||
}
|
||||
|
||||
public static final Type<ScreenLoadHandler> TYPE = new Type<ScreenLoadHandler>();
|
||||
public static final Type<ScreenLoadHandler> TYPE = new Type<>();
|
||||
|
||||
@Override
|
||||
protected void dispatch(ScreenLoadHandler handler) {
|
||||
|
@@ -50,7 +50,7 @@ class DirectChangeByCommit extends HttpServlet {
|
||||
protected void doGet(final HttpServletRequest req,
|
||||
final HttpServletResponse rsp) throws IOException {
|
||||
String query = CharMatcher.is('/').trimTrailingFrom(req.getPathInfo());
|
||||
HashSet<Change.Id> ids = new HashSet<Change.Id>();
|
||||
HashSet<Change.Id> ids = new HashSet<>();
|
||||
try {
|
||||
ChangeQueryBuilder builder = queryBuilder.create(currentUser.get());
|
||||
Predicate<ChangeData> visibleToMe = builder.is_visible();
|
||||
|
@@ -152,7 +152,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
reportBugUrl : "http://code.google.com/p/gerrit/issues/list");
|
||||
config.setReportBugText(cfg.getString("gerrit", null, "reportBugText"));
|
||||
|
||||
final Set<Account.FieldName> fields = new HashSet<Account.FieldName>();
|
||||
final Set<Account.FieldName> fields = new HashSet<>();
|
||||
for (final Account.FieldName n : Account.FieldName.values()) {
|
||||
if (realm.allowsEdit(n)) {
|
||||
fields.add(n);
|
||||
|
@@ -356,7 +356,7 @@ public class GitOverHttpServlet extends GitServlet {
|
||||
|
||||
if (isGet) {
|
||||
cache.put(cacheKey, Collections.unmodifiableSet(
|
||||
new HashSet<ObjectId>(rp.getAdvertisedObjects())));
|
||||
new HashSet<>(rp.getAdvertisedObjects())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -231,7 +231,7 @@ class ProjectDigestFilter implements Filter {
|
||||
}
|
||||
|
||||
private Map<String, String> parseAuthorization(String auth) {
|
||||
Map<String, String> p = new HashMap<String, String>();
|
||||
Map<String, String> p = new HashMap<>();
|
||||
int next = "Digest ".length();
|
||||
while (next < auth.length()) {
|
||||
if (next < auth.length() && auth.charAt(next) == ',') {
|
||||
|
@@ -98,7 +98,7 @@ class GitWebServlet extends HttpServlet {
|
||||
this.projectControl = projectControl;
|
||||
this.anonymousUserProvider = anonymousUserProvider;
|
||||
this.gitwebCgi = gitWebConfig.getGitwebCGI();
|
||||
this.deniedActions = new HashSet<String>();
|
||||
this.deniedActions = new HashSet<>();
|
||||
|
||||
final String url = gitWebConfig.getUrl();
|
||||
if ((url != null) && (!url.equals("gitweb"))) {
|
||||
@@ -398,7 +398,7 @@ class GitWebServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
private static Map<String, String> getParameters(HttpServletRequest req) {
|
||||
final Map<String, String> params = new HashMap<String, String>();
|
||||
final Map<String, String> params = new HashMap<>();
|
||||
for (final String pair : req.getQueryString().split("[&;]")) {
|
||||
final int eq = pair.indexOf('=');
|
||||
if (0 < eq) {
|
||||
@@ -669,11 +669,11 @@ class GitWebServlet extends HttpServlet {
|
||||
private Map<String, String> envMap;
|
||||
|
||||
EnvList() {
|
||||
envMap = new HashMap<String, String>();
|
||||
envMap = new HashMap<>();
|
||||
}
|
||||
|
||||
EnvList(final EnvList l) {
|
||||
envMap = new HashMap<String, String>(l.envMap);
|
||||
envMap = new HashMap<>(l.envMap);
|
||||
}
|
||||
|
||||
/** Set a name/value pair, null values will be treated as an empty String */
|
||||
|
@@ -51,9 +51,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||
final class GerritJsonServlet extends JsonServlet<GerritJsonServlet.GerritCall> {
|
||||
private static final Logger log = LoggerFactory.getLogger(GerritJsonServlet.class);
|
||||
private static final ThreadLocal<GerritCall> currentCall =
|
||||
new ThreadLocal<GerritCall>();
|
||||
new ThreadLocal<>();
|
||||
private static final ThreadLocal<MethodHandle> currentMethod =
|
||||
new ThreadLocal<MethodHandle>();
|
||||
new ThreadLocal<>();
|
||||
private final Provider<WebSession> session;
|
||||
private final RemoteJsonService service;
|
||||
private final AuditService audit;
|
||||
|
@@ -137,8 +137,7 @@ class SuggestServiceImpl extends BaseServiceImplementation implements
|
||||
final int max = 10;
|
||||
final int n = limit <= 0 ? max : Math.min(limit, max);
|
||||
|
||||
final LinkedHashMap<Account.Id, AccountInfo> r =
|
||||
new LinkedHashMap<Account.Id, AccountInfo>();
|
||||
LinkedHashMap<Account.Id, AccountInfo> r = new LinkedHashMap<>();
|
||||
for (final Account p : db.accounts().suggestByFullName(a, b, n)) {
|
||||
addSuggestion(r, p, new AccountInfo(p), active, visibilityControl);
|
||||
}
|
||||
@@ -159,7 +158,7 @@ class SuggestServiceImpl extends BaseServiceImplementation implements
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<AccountInfo>(r.values());
|
||||
return new ArrayList<>(r.values());
|
||||
}
|
||||
|
||||
private void addSuggestion(Map<Account.Id, AccountInfo> map, Account account,
|
||||
@@ -251,7 +250,7 @@ class SuggestServiceImpl extends BaseServiceImplementation implements
|
||||
final List<AccountInfo> suggestedAccounts =
|
||||
suggestAccount(db, query, Boolean.TRUE, limit, visibilityControl);
|
||||
final List<ReviewerInfo> reviewer =
|
||||
new ArrayList<ReviewerInfo>(suggestedAccounts.size());
|
||||
new ArrayList<>(suggestedAccounts.size());
|
||||
for (final AccountInfo a : suggestedAccounts) {
|
||||
reviewer.add(new ReviewerInfo(a));
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ class SystemInfoServiceImpl implements SystemInfoService {
|
||||
}
|
||||
|
||||
public void daemonHostKeys(final AsyncCallback<List<SshHostKey>> callback) {
|
||||
final ArrayList<SshHostKey> r = new ArrayList<SshHostKey>(hostKeys.size());
|
||||
final ArrayList<SshHostKey> r = new ArrayList<>(hostKeys.size());
|
||||
for (final HostKey hk : hostKeys) {
|
||||
String host = hk.getHost();
|
||||
if (host.startsWith("*:")) {
|
||||
|
@@ -113,8 +113,7 @@ class AccountServiceImpl extends BaseServiceImplementation implements
|
||||
final AsyncCallback<List<AccountProjectWatchInfo>> callback) {
|
||||
run(callback, new Action<List<AccountProjectWatchInfo>>() {
|
||||
public List<AccountProjectWatchInfo> run(ReviewDb db) throws OrmException {
|
||||
final List<AccountProjectWatchInfo> r =
|
||||
new ArrayList<AccountProjectWatchInfo>();
|
||||
List<AccountProjectWatchInfo> r = new ArrayList<>();
|
||||
|
||||
for (final AccountProjectWatch w : db.accountProjectWatches()
|
||||
.byAccount(getAccountId()).toList()) {
|
||||
|
@@ -63,7 +63,7 @@ class DeleteExternalIds extends Handler<Set<AccountExternalId.Key>> {
|
||||
public Set<AccountExternalId.Key> call() throws OrmException {
|
||||
final Map<AccountExternalId.Key, AccountExternalId> have = have();
|
||||
|
||||
List<AccountExternalId> toDelete = new ArrayList<AccountExternalId>();
|
||||
List<AccountExternalId> toDelete = new ArrayList<>();
|
||||
for (AccountExternalId.Key k : keys) {
|
||||
final AccountExternalId id = have.get(k);
|
||||
if (id != null && id.canDelete()) {
|
||||
@@ -86,7 +86,7 @@ class DeleteExternalIds extends Handler<Set<AccountExternalId.Key>> {
|
||||
throws OrmException {
|
||||
Map<AccountExternalId.Key, AccountExternalId> r;
|
||||
|
||||
r = new HashMap<AccountExternalId.Key, AccountExternalId>();
|
||||
r = new HashMap<>();
|
||||
for (AccountExternalId i : detailFactory.call()) {
|
||||
r.put(i.getKey(), i);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class DeleteExternalIds extends Handler<Set<AccountExternalId.Key>> {
|
||||
}
|
||||
|
||||
private Set<AccountExternalId.Key> toKeySet(List<AccountExternalId> toDelete) {
|
||||
Set<AccountExternalId.Key> r = new HashSet<AccountExternalId.Key>();
|
||||
Set<AccountExternalId.Key> r = new HashSet<>();
|
||||
for (AccountExternalId i : toDelete) {
|
||||
r.add(i.getKey());
|
||||
}
|
||||
|
@@ -138,7 +138,7 @@ class PatchSetDetailFactory extends Handler<PatchSetDetail> {
|
||||
}
|
||||
|
||||
final List<Patch> patches = list.toPatchList(patchSet.getId());
|
||||
final Map<Patch.Key, Patch> byKey = new HashMap<Patch.Key, Patch>();
|
||||
final Map<Patch.Key, Patch> byKey = new HashMap<>();
|
||||
for (final Patch p : patches) {
|
||||
byKey.put(p.getKey(), p);
|
||||
}
|
||||
|
@@ -114,8 +114,8 @@ class ProjectAccessFactory extends Handler<ProjectAccess> {
|
||||
}
|
||||
|
||||
final RefControl metaConfigControl = pc.controlForRef(RefNames.REFS_CONFIG);
|
||||
List<AccessSection> local = new ArrayList<AccessSection>();
|
||||
Set<String> ownerOf = new HashSet<String>();
|
||||
List<AccessSection> local = new ArrayList<>();
|
||||
Set<String> ownerOf = new HashSet<>();
|
||||
Map<AccountGroup.UUID, Boolean> visibleGroups = new HashMap<>();
|
||||
|
||||
for (AccessSection section : config.getAccessSections()) {
|
||||
|
@@ -185,7 +185,7 @@ public abstract class ProjectAccessHandler<T> extends Handler<T> {
|
||||
}
|
||||
|
||||
private static Set<String> scanSectionNames(ProjectConfig config) {
|
||||
Set<String> names = new HashSet<String>();
|
||||
Set<String> names = new HashSet<>();
|
||||
for (AccessSection section : config.getAccessSections()) {
|
||||
names.add(section.getName());
|
||||
}
|
||||
|
@@ -182,7 +182,7 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
|
||||
private void insertAncestors(PatchSet.Id id, RevCommit src)
|
||||
throws OrmException {
|
||||
final int cnt = src.getParentCount();
|
||||
List<PatchSetAncestor> toInsert = new ArrayList<PatchSetAncestor>(cnt);
|
||||
List<PatchSetAncestor> toInsert = new ArrayList<>(cnt);
|
||||
for (int p = 0; p < cnt; p++) {
|
||||
PatchSetAncestor a;
|
||||
|
||||
|
@@ -192,7 +192,7 @@ public final class GerritLauncher {
|
||||
throw e;
|
||||
}
|
||||
|
||||
final SortedMap<String, URL> jars = new TreeMap<String, URL>();
|
||||
final SortedMap<String, URL> jars = new TreeMap<>();
|
||||
try {
|
||||
final ZipFile zf = new ZipFile(path);
|
||||
try {
|
||||
@@ -220,7 +220,7 @@ public final class GerritLauncher {
|
||||
|
||||
// The extension API needs to be its own ClassLoader, along
|
||||
// with a few of its dependencies. Try to construct this first.
|
||||
List<URL> extapi = new ArrayList<URL>();
|
||||
List<URL> extapi = new ArrayList<>();
|
||||
move(jars, "gerrit-extension-api-", extapi);
|
||||
move(jars, "guice-", extapi);
|
||||
move(jars, "javax.inject-1.jar", extapi);
|
||||
@@ -592,7 +592,7 @@ public final class GerritLauncher {
|
||||
private static ClassLoader useDevClasspath()
|
||||
throws MalformedURLException, FileNotFoundException {
|
||||
File out = getDeveloperBuckOut();
|
||||
List<URL> dirs = new ArrayList<URL>();
|
||||
List<URL> dirs = new ArrayList<>();
|
||||
dirs.add(new File(new File(out, "eclipse"), "classes").toURI().toURL());
|
||||
ClassLoader cl = GerritLauncher.class.getClassLoader();
|
||||
for (URL u : ((URLClassLoader) cl).getURLs()) {
|
||||
|
@@ -185,7 +185,7 @@ public class BaseInit extends SiteProgram {
|
||||
private SiteInit createSiteInit() {
|
||||
final ConsoleUI ui = getConsoleUI();
|
||||
final File sitePath = getSitePath();
|
||||
final List<Module> m = new ArrayList<Module>();
|
||||
final List<Module> m = new ArrayList<>();
|
||||
|
||||
m.add(new InitModule(standalone, initDb));
|
||||
m.add(new AbstractModule() {
|
||||
@@ -250,7 +250,7 @@ public class BaseInit extends SiteProgram {
|
||||
}
|
||||
|
||||
void upgradeSchema() throws OrmException {
|
||||
final List<String> pruneList = new ArrayList<String>();
|
||||
final List<String> pruneList = new ArrayList<>();
|
||||
schemaUpdater.update(new UpdateUI() {
|
||||
@Override
|
||||
public void message(String msg) {
|
||||
@@ -316,7 +316,7 @@ public class BaseInit extends SiteProgram {
|
||||
}
|
||||
|
||||
private Injector createSysInjector(final SiteInit init) {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
final List<Module> modules = new ArrayList<>();
|
||||
modules.add(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
@@ -303,13 +303,13 @@ public class Daemon extends SiteProgram {
|
||||
}
|
||||
|
||||
private Injector createCfgInjector() {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
final List<Module> modules = new ArrayList<>();
|
||||
modules.add(new AuthConfigModule());
|
||||
return dbInjector.createChildInjector(modules);
|
||||
}
|
||||
|
||||
private Injector createSysInjector() {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
final List<Module> modules = new ArrayList<>();
|
||||
modules.add(SchemaVersionCheck.module());
|
||||
modules.add(new LogFileCompressor.Module());
|
||||
modules.add(new WorkQueue.Module());
|
||||
@@ -376,7 +376,7 @@ public class Daemon extends SiteProgram {
|
||||
}
|
||||
|
||||
private Injector createSshInjector() {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
final List<Module> modules = new ArrayList<>();
|
||||
modules.add(sysInjector.getInstance(SshModule.class));
|
||||
if (!test) {
|
||||
modules.add(new SshHostKeyModule());
|
||||
@@ -401,7 +401,7 @@ public class Daemon extends SiteProgram {
|
||||
}
|
||||
|
||||
private Injector createWebInjector() {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
final List<Module> modules = new ArrayList<>();
|
||||
if (sshd) {
|
||||
modules.add(new ProjectQoSFilter.Module());
|
||||
}
|
||||
@@ -429,7 +429,7 @@ public class Daemon extends SiteProgram {
|
||||
}
|
||||
|
||||
private Injector createHttpdInjector() {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
final List<Module> modules = new ArrayList<>();
|
||||
modules.add(new JettyModule(new JettyEnv(webInjector)));
|
||||
return webInjector.createChildInjector(modules);
|
||||
}
|
||||
|
@@ -70,7 +70,7 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
|
||||
db.close();
|
||||
}
|
||||
|
||||
final List<Worker> workers = new ArrayList<Worker>(threads);
|
||||
final List<Worker> workers = new ArrayList<>(threads);
|
||||
for (int tid = 0; tid < threads; tid++) {
|
||||
Worker t = new Worker();
|
||||
t.start();
|
||||
|
@@ -33,7 +33,7 @@ import java.util.List;
|
||||
|
||||
public class PrologShell extends AbstractProgram {
|
||||
@Option(name = "-s", metaVar = "FILE.pl", usage = "file to load")
|
||||
private List<String> fileName = new ArrayList<String>();
|
||||
private List<String> fileName = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int run() {
|
||||
|
@@ -252,7 +252,7 @@ public class Reindex extends SiteProgram {
|
||||
Key.get(new TypeLiteral<SchemaFactory<ReviewDb>>() {}));
|
||||
final List<ReviewDb> dbs = Collections.synchronizedList(
|
||||
Lists.<ReviewDb> newArrayListWithCapacity(threads + 1));
|
||||
final ThreadLocal<ReviewDb> localDb = new ThreadLocal<ReviewDb>();
|
||||
final ThreadLocal<ReviewDb> localDb = new ThreadLocal<>();
|
||||
|
||||
bind(ReviewDb.class).toProvider(new Provider<ReviewDb>() {
|
||||
@Override
|
||||
|
@@ -47,7 +47,7 @@ public class Rulec extends SiteProgram {
|
||||
private boolean quiet;
|
||||
|
||||
@Argument(index = 0, multiValued = true, metaVar = "PROJECT", usage = "project to compile rules for")
|
||||
private List<String> projectNames = new ArrayList<String>();
|
||||
private List<String> projectNames = new ArrayList<>();
|
||||
|
||||
private Injector dbInjector;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Rulec extends SiteProgram {
|
||||
}
|
||||
}).injectMembers(this);
|
||||
|
||||
LinkedHashSet<Project.NameKey> names = new LinkedHashSet<Project.NameKey>();
|
||||
LinkedHashSet<Project.NameKey> names = new LinkedHashSet<>();
|
||||
for (String name : projectNames) {
|
||||
names.add(new Project.NameKey(name));
|
||||
}
|
||||
|
@@ -371,7 +371,7 @@ public class JettyServer {
|
||||
|
||||
private Handler makeContext(final JettyEnv env, final Config cfg)
|
||||
throws MalformedURLException, IOException {
|
||||
final Set<String> paths = new HashSet<String>();
|
||||
final Set<String> paths = new HashSet<>();
|
||||
for (URI u : listenURLs(cfg)) {
|
||||
String p = u.getPath();
|
||||
if (p == null || p.isEmpty()) {
|
||||
@@ -383,7 +383,7 @@ public class JettyServer {
|
||||
paths.add(p);
|
||||
}
|
||||
|
||||
final List<ContextHandler> all = new ArrayList<ContextHandler>();
|
||||
final List<ContextHandler> all = new ArrayList<>();
|
||||
for (String path : paths) {
|
||||
all.add(makeContext(path, env, cfg));
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ public class InitPluginStepsLoader {
|
||||
|
||||
public Collection<InitStep> getInitSteps() {
|
||||
List<File> jars = scanJarsInPluginsDirectory();
|
||||
ArrayList<InitStep> pluginsInitSteps = new ArrayList<InitStep>();
|
||||
ArrayList<InitStep> pluginsInitSteps = new ArrayList<>();
|
||||
|
||||
for (File jar : jars) {
|
||||
InitStep init = loadInitStep(jar);
|
||||
|
@@ -55,7 +55,7 @@ public class Section {
|
||||
}
|
||||
|
||||
public void set(final String name, final String value) {
|
||||
final ArrayList<String> all = new ArrayList<String>();
|
||||
final ArrayList<String> all = new ArrayList<>();
|
||||
all.addAll(Arrays.asList(flags.cfg.getStringList(section, subsection, name)));
|
||||
|
||||
if (value != null) {
|
||||
|
@@ -125,7 +125,7 @@ public class SitePathInitializer {
|
||||
}
|
||||
|
||||
private static List<InitStep> stepsOf(final Injector injector) {
|
||||
final ArrayList<InitStep> r = new ArrayList<InitStep>();
|
||||
final ArrayList<InitStep> r = new ArrayList<>();
|
||||
for (Binding<InitStep> b : all(injector)) {
|
||||
r.add(b.getProvider().get());
|
||||
}
|
||||
|
@@ -85,7 +85,7 @@ public class JythonShell {
|
||||
} catch (IllegalAccessException e) {
|
||||
throw noInterpreter(e);
|
||||
}
|
||||
injectedVariables = new ArrayList<String>();
|
||||
injectedVariables = new ArrayList<>();
|
||||
set("Shell", this);
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ public class RuntimeShutdown {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(ShutdownCallback.class);
|
||||
|
||||
private final List<Runnable> tasks = new ArrayList<Runnable>();
|
||||
private final List<Runnable> tasks = new ArrayList<>();
|
||||
private boolean shutdownStarted;
|
||||
private boolean shutdownComplete;
|
||||
|
||||
|
@@ -90,7 +90,7 @@ public abstract class SiteProgram extends AbstractProgram {
|
||||
/** @return provides database connectivity and site path. */
|
||||
protected Injector createDbInjector(final DataSourceProvider.Context context) {
|
||||
final File sitePath = getSitePath();
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
final List<Module> modules = new ArrayList<>();
|
||||
|
||||
Module sitePathModule = new AbstractModule() {
|
||||
@Override
|
||||
|
@@ -27,7 +27,7 @@ public class HelloMenu implements TopMenu {
|
||||
|
||||
@Inject
|
||||
public HelloMenu(@PluginName String pluginName) {
|
||||
menuEntries = new ArrayList<TopMenu.MenuEntry>();
|
||||
menuEntries = new ArrayList<>();
|
||||
menuEntries.add(new MenuEntry("Hello", Collections
|
||||
.singletonList(new MenuItem("Hello Screen", "#/x/" + pluginName, ""))));
|
||||
}
|
||||
|
@@ -125,7 +125,7 @@ public abstract class PrettyFormatter implements SparseHtmlFile {
|
||||
public void format(SparseFileContent src) {
|
||||
content = new SparseFileContent();
|
||||
content.setSize(src.size());
|
||||
trailingEdits = new HashSet<Integer>();
|
||||
trailingEdits = new HashSet<>();
|
||||
|
||||
String html = toHTML(src);
|
||||
|
||||
@@ -365,7 +365,7 @@ public abstract class PrettyFormatter implements SparseHtmlFile {
|
||||
// in the source. That simplifies our loop below because we'll never
|
||||
// run off the end of the edit list.
|
||||
//
|
||||
List<Edit> edits = new ArrayList<Edit>(this.edits.size() + 1);
|
||||
List<Edit> edits = new ArrayList<>(this.edits.size() + 1);
|
||||
edits.addAll(this.edits);
|
||||
edits.add(new Edit(src.size(), src.size()));
|
||||
|
||||
|
@@ -29,7 +29,7 @@ public class SparseFileContent {
|
||||
private transient int currentRangeIdx;
|
||||
|
||||
public SparseFileContent() {
|
||||
ranges = new ArrayList<Range>();
|
||||
ranges = new ArrayList<>();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
@@ -222,7 +222,7 @@ public class SparseFileContent {
|
||||
|
||||
public SparseFileContent apply(SparseFileContent a, List<Edit> edits) {
|
||||
EditList list = new EditList(edits, size, a.size(), size);
|
||||
ArrayList<String> lines = new ArrayList<String>(size);
|
||||
ArrayList<String> lines = new ArrayList<>(size);
|
||||
for (final EditList.Hunk hunk : list.getHunks()) {
|
||||
while (hunk.next()) {
|
||||
if (hunk.isContextLine()) {
|
||||
@@ -277,7 +277,7 @@ public class SparseFileContent {
|
||||
|
||||
private Range(final int b) {
|
||||
base = b;
|
||||
lines = new ArrayList<String>();
|
||||
lines = new ArrayList<>();
|
||||
}
|
||||
|
||||
protected Range() {
|
||||
|
@@ -156,7 +156,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
/** Listeners to receive changes as they happen (limited by visibility
|
||||
* of holder's user). */
|
||||
private final Map<ChangeListener, ChangeListenerHolder> listeners =
|
||||
new ConcurrentHashMap<ChangeListener, ChangeListenerHolder>();
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
/** Listeners to receive all changes as they happen. */
|
||||
private final DynamicSet<ChangeListener> unrestrictedListeners;
|
||||
@@ -320,7 +320,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
public HookResult doRefUpdateHook(final Project project, final String refname,
|
||||
final Account uploader, final ObjectId oldId, final ObjectId newId) {
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--project", project.getName());
|
||||
addArg(args, "--refname", refname);
|
||||
addArg(args, "--uploader", getDisplayName(uploader));
|
||||
@@ -355,7 +355,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.uploader = eventFactory.asAccountAttribute(uploader.getAccount());
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--is-draft", patchSet.isDraft() ? "true" : "false");
|
||||
addArg(args, "--change-url", event.change.url);
|
||||
@@ -379,7 +379,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.uploader = eventFactory.asAccountAttribute(uploader.getAccount());
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--change-url", event.change.url);
|
||||
addArg(args, "--project", event.change.project);
|
||||
@@ -413,7 +413,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--is-draft", patchSet.isDraft() ? "true" : "false");
|
||||
addArg(args, "--change-url", event.change.url);
|
||||
@@ -442,7 +442,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.patchSet = eventFactory.asPatchSetAttribute(patchSet);
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--change-url", event.change.url);
|
||||
addArg(args, "--project", event.change.project);
|
||||
@@ -465,7 +465,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.reason = reason;
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--change-url", event.change.url);
|
||||
addArg(args, "--project", event.change.project);
|
||||
@@ -489,7 +489,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.reason = reason;
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--change-url", event.change.url);
|
||||
addArg(args, "--project", event.change.project);
|
||||
@@ -513,7 +513,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.reason = reason;
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--change-url", event.change.url);
|
||||
addArg(args, "--project", event.change.project);
|
||||
@@ -539,7 +539,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.refUpdate = eventFactory.asRefUpdateAttribute(oldId, newId, refName);
|
||||
fireEvent(refName, event);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--oldrev", event.refUpdate.oldRev);
|
||||
addArg(args, "--newrev", event.refUpdate.newRev);
|
||||
addArg(args, "--refname", event.refUpdate.refName);
|
||||
@@ -560,7 +560,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.reviewer = eventFactory.asAccountAttribute(account);
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--change-url", event.change.url);
|
||||
addArg(args, "--project", event.change.project);
|
||||
@@ -580,7 +580,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.oldTopic = oldTopic;
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--project", event.change.project);
|
||||
addArg(args, "--branch", event.change.branch);
|
||||
@@ -593,7 +593,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
|
||||
public void doClaSignupHook(Account account, ContributorAgreement cla) {
|
||||
if (account != null) {
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--submitter", getDisplayName(account));
|
||||
addArg(args, "--user-id", account.getId().toString());
|
||||
addArg(args, "--cla-name", cla.getName());
|
||||
@@ -721,7 +721,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
}
|
||||
|
||||
SyncHookTask syncHook = new SyncHookTask(project, hook, args);
|
||||
FutureTask<HookResult> task = new FutureTask<HookResult>(syncHook);
|
||||
FutureTask<HookResult> task = new FutureTask<>(syncHook);
|
||||
|
||||
syncHookThreadPool.execute(task);
|
||||
|
||||
@@ -781,7 +781,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
HookResult result = null;
|
||||
try {
|
||||
|
||||
final List<String> argv = new ArrayList<String>(1 + args.size());
|
||||
final List<String> argv = new ArrayList<>(1 + args.size());
|
||||
argv.add(hook.getAbsolutePath());
|
||||
argv.addAll(args);
|
||||
|
||||
|
@@ -154,13 +154,13 @@ public class PrologCompiler implements Callable<PrologCompiler.Status> {
|
||||
}
|
||||
|
||||
DiagnosticCollector<JavaFileObject> diagnostics =
|
||||
new DiagnosticCollector<JavaFileObject>();
|
||||
new DiagnosticCollector<>();
|
||||
StandardJavaFileManager fileManager =
|
||||
compiler.getStandardFileManager(diagnostics, null, null);
|
||||
try {
|
||||
Iterable<? extends JavaFileObject> compilationUnits = fileManager
|
||||
.getJavaFileObjectsFromFiles(getAllFiles(tempDir, ".java"));
|
||||
ArrayList<String> options = new ArrayList<String>();
|
||||
ArrayList<String> options = new ArrayList<>();
|
||||
String classpath = getMyClasspath();
|
||||
if (classpath != null) {
|
||||
options.add("-classpath");
|
||||
@@ -270,7 +270,7 @@ public class PrologCompiler implements Callable<PrologCompiler.Status> {
|
||||
}
|
||||
|
||||
private List<File> getAllFiles(File dir, String extension) {
|
||||
ArrayList<File> fileList = new ArrayList<File>();
|
||||
ArrayList<File> fileList = new ArrayList<>();
|
||||
getAllFiles(dir, extension, fileList);
|
||||
return fileList;
|
||||
}
|
||||
@@ -287,7 +287,7 @@ public class PrologCompiler implements Callable<PrologCompiler.Status> {
|
||||
}
|
||||
|
||||
private List<String> getRelativePaths(File dir, String extension) {
|
||||
ArrayList<String> pathList = new ArrayList<String>();
|
||||
ArrayList<String> pathList = new ArrayList<>();
|
||||
getRelativePaths(dir, extension, "", pathList);
|
||||
return pathList;
|
||||
}
|
||||
|
@@ -73,8 +73,8 @@ public class PrologEnvironment extends BufferingPrologControl {
|
||||
setMaxArity(MAX_ARITY);
|
||||
setEnabled(EnumSet.allOf(Prolog.Feature.class), false);
|
||||
args = a;
|
||||
storedValues = new HashMap<StoredValue<Object>, Object>();
|
||||
cleanup = new LinkedList<Runnable>();
|
||||
storedValues = new HashMap<>();
|
||||
cleanup = new LinkedList<>();
|
||||
}
|
||||
|
||||
public Args getArgs() {
|
||||
|
@@ -80,11 +80,10 @@ public class RulesCache {
|
||||
private static final List<String> PACKAGE_LIST = ImmutableList.of(
|
||||
Prolog.BUILTIN, "gerrit");
|
||||
|
||||
private final Map<ObjectId, MachineRef> machineCache =
|
||||
new HashMap<ObjectId, MachineRef>();
|
||||
private final Map<ObjectId, MachineRef> machineCache = new HashMap<>();
|
||||
|
||||
private final ReferenceQueue<PrologMachineCopy> dead =
|
||||
new ReferenceQueue<PrologMachineCopy>();
|
||||
new ReferenceQueue<>();
|
||||
|
||||
private static final class MachineRef extends WeakReference<PrologMachineCopy> {
|
||||
final ObjectId key;
|
||||
|
@@ -25,12 +25,12 @@ import com.googlecode.prolog_cafe.lang.SystemException;
|
||||
public class StoredValue<T> {
|
||||
/** Construct a new unique key that does not match any other key. */
|
||||
public static <T> StoredValue<T> create() {
|
||||
return new StoredValue<T>();
|
||||
return new StoredValue<>();
|
||||
}
|
||||
|
||||
/** Construct a key based on a Java Class object, useful for singletons. */
|
||||
public static <T> StoredValue<T> create(Class<T> clazz) {
|
||||
return new StoredValue<T>(clazz);
|
||||
return new StoredValue<>(clazz);
|
||||
}
|
||||
|
||||
private final Object key;
|
||||
|
@@ -147,7 +147,7 @@ public class ChangeUtil {
|
||||
public static void insertAncestors(ReviewDb db, PatchSet.Id id, RevCommit src)
|
||||
throws OrmException {
|
||||
int cnt = src.getParentCount();
|
||||
List<PatchSetAncestor> toInsert = new ArrayList<PatchSetAncestor>(cnt);
|
||||
List<PatchSetAncestor> toInsert = new ArrayList<>(cnt);
|
||||
for (int p = 0; p < cnt; p++) {
|
||||
PatchSetAncestor a =
|
||||
new PatchSetAncestor(new PatchSetAncestor.Id(id, p + 1));
|
||||
|
@@ -94,7 +94,7 @@ public class MimeUtilFileTypeRegistry implements FileTypeRegistry {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public MimeType getMimeType(final String path, final byte[] content) {
|
||||
Set<MimeType> mimeTypes = new HashSet<MimeType>();
|
||||
Set<MimeType> mimeTypes = new HashSet<>();
|
||||
if (content != null && content.length > 0) {
|
||||
try {
|
||||
mimeTypes.addAll(mimeUtil.getMimeTypes(content));
|
||||
@@ -112,7 +112,7 @@ public class MimeUtilFileTypeRegistry implements FileTypeRegistry {
|
||||
return MimeUtil2.UNKNOWN_MIME_TYPE;
|
||||
}
|
||||
|
||||
final List<MimeType> types = new ArrayList<MimeType>(mimeTypes);
|
||||
final List<MimeType> types = new ArrayList<>(mimeTypes);
|
||||
Collections.sort(types, new Comparator<MimeType>() {
|
||||
@Override
|
||||
public int compare(MimeType a, MimeType b) {
|
||||
|
@@ -32,7 +32,7 @@ public class RequestCleanup implements Runnable {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(RequestCleanup.class);
|
||||
|
||||
private final List<Runnable> cleanup = new LinkedList<Runnable>();
|
||||
private final List<Runnable> cleanup = new LinkedList<>();
|
||||
private boolean ran;
|
||||
|
||||
/** Register a task to be completed after the request ends. */
|
||||
|
@@ -157,8 +157,7 @@ public class ListAccess implements RestReadView<TopLevelResource> {
|
||||
pc.controlForRef(RefNames.REFS_CONFIG);
|
||||
local = Maps.newHashMap();
|
||||
ownerOf = Sets.newHashSet();
|
||||
Map<AccountGroup.UUID, Boolean> visibleGroups =
|
||||
new HashMap<AccountGroup.UUID, Boolean>();
|
||||
Map<AccountGroup.UUID, Boolean> visibleGroups = new HashMap<>();
|
||||
|
||||
for (AccessSection section : config.getAccessSections()) {
|
||||
String name = section.getName();
|
||||
|
@@ -163,7 +163,7 @@ public class AccountCacheImpl implements AccountCache {
|
||||
Collections.unmodifiableCollection(db.accountExternalIds().byAccount(
|
||||
who).toList());
|
||||
|
||||
Set<AccountGroup.UUID> internalGroups = new HashSet<AccountGroup.UUID>();
|
||||
Set<AccountGroup.UUID> internalGroups = new HashSet<>();
|
||||
for (AccountGroupMember g : db.accountGroupMembers().byAccount(who)) {
|
||||
final AccountGroup.Id groupId = g.getAccountGroupId();
|
||||
final AccountGroup group = groupCache.get(groupId);
|
||||
|
@@ -36,7 +36,7 @@ public class AccountInfoCacheFactory {
|
||||
@Inject
|
||||
AccountInfoCacheFactory(final AccountCache accountCache) {
|
||||
this.accountCache = accountCache;
|
||||
this.out = new HashMap<Account.Id, Account>();
|
||||
this.out = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class AccountInfoCacheFactory {
|
||||
* Create an AccountInfoCache with the currently loaded Account entities.
|
||||
* */
|
||||
public AccountInfoCache create() {
|
||||
final List<AccountInfo> r = new ArrayList<AccountInfo>(out.size());
|
||||
final List<AccountInfo> r = new ArrayList<>(out.size());
|
||||
for (final Account a : out.values()) {
|
||||
r.add(new AccountInfo(a));
|
||||
}
|
||||
|
@@ -200,8 +200,8 @@ public class AccountManager {
|
||||
if (authConfig.isAllowGoogleAccountUpgrade()
|
||||
&& who.isScheme(OpenIdUrls.URL_GOOGLE + "?")
|
||||
&& who.getEmailAddress() != null) {
|
||||
final List<AccountExternalId> openId = new ArrayList<AccountExternalId>();
|
||||
final List<AccountExternalId> v1 = new ArrayList<AccountExternalId>();
|
||||
final List<AccountExternalId> openId = new ArrayList<>();
|
||||
final List<AccountExternalId> v1 = new ArrayList<>();
|
||||
|
||||
for (final AccountExternalId extId : db.accountExternalIds()
|
||||
.byEmailAddress(who.getEmailAddress())) {
|
||||
|
@@ -179,7 +179,7 @@ public class AccountResolver {
|
||||
// At this point we have no clue. Just perform a whole bunch of suggestions
|
||||
// and pray we come up with a reasonable result list.
|
||||
//
|
||||
Set<Account.Id> result = new HashSet<Account.Id>();
|
||||
Set<Account.Id> result = new HashSet<>();
|
||||
String a = nameOrEmail;
|
||||
String b = nameOrEmail + "\u9fa5";
|
||||
for (Account act : schema.get().accounts().suggestByFullName(a, b, 10)) {
|
||||
|
@@ -74,7 +74,7 @@ public class AccountState {
|
||||
* validated by Gerrit directly.
|
||||
*/
|
||||
public Set<String> getEmailAddresses() {
|
||||
final Set<String> emails = new HashSet<String>();
|
||||
final Set<String> emails = new HashSet<>();
|
||||
for (final AccountExternalId e : externalIds) {
|
||||
if (e.getEmailAddress() != null && !e.getEmailAddress().isEmpty()) {
|
||||
emails.add(e.getEmailAddress());
|
||||
|
@@ -43,8 +43,7 @@ public class CapabilityCollection {
|
||||
section = new AccessSection(AccessSection.GLOBAL_CAPABILITIES);
|
||||
}
|
||||
|
||||
Map<String, List<PermissionRule>> tmp =
|
||||
new HashMap<String, List<PermissionRule>>();
|
||||
Map<String, List<PermissionRule>> tmp = new HashMap<>();
|
||||
for (Permission permission : section.getPermissions()) {
|
||||
for (PermissionRule rule : permission.getRules()) {
|
||||
if (!permission.getName().equals(GlobalCapability.EMAIL_REVIEWERS)
|
||||
@@ -54,7 +53,7 @@ public class CapabilityCollection {
|
||||
|
||||
List<PermissionRule> r = tmp.get(permission.getName());
|
||||
if (r == null) {
|
||||
r = new ArrayList<PermissionRule>(2);
|
||||
r = new ArrayList<>(2);
|
||||
tmp.put(permission.getName(), r);
|
||||
}
|
||||
r.add(rule);
|
||||
@@ -62,8 +61,7 @@ public class CapabilityCollection {
|
||||
}
|
||||
configureDefaults(tmp, section);
|
||||
|
||||
Map<String, List<PermissionRule>> res =
|
||||
new HashMap<String, List<PermissionRule>>();
|
||||
Map<String, List<PermissionRule>> res = new HashMap<>();
|
||||
for (Map.Entry<String, List<PermissionRule>> e : tmp.entrySet()) {
|
||||
List<PermissionRule> rules = e.getValue();
|
||||
if (rules.size() == 1) {
|
||||
|
@@ -54,7 +54,7 @@ public class CapabilityControl {
|
||||
CapabilityControl(ProjectCache projectCache, @Assisted CurrentUser currentUser) {
|
||||
capabilities = projectCache.getAllProjects().getCapabilityCollection();
|
||||
user = currentUser;
|
||||
effective = new HashMap<String, List<PermissionRule>>();
|
||||
effective = new HashMap<>();
|
||||
}
|
||||
|
||||
/** Identity of the user the control will compute for. */
|
||||
@@ -268,7 +268,7 @@ public class CapabilityControl {
|
||||
return rules;
|
||||
}
|
||||
|
||||
List<PermissionRule> mine = new ArrayList<PermissionRule>(rules.size());
|
||||
List<PermissionRule> mine = new ArrayList<>(rules.size());
|
||||
for (PermissionRule rule : rules) {
|
||||
if (match(groups, rule)) {
|
||||
mine.add(rule);
|
||||
|
@@ -141,7 +141,7 @@ public class ChangeUserName implements Callable<VoidResult> {
|
||||
}
|
||||
|
||||
private Collection<AccountExternalId> old() throws OrmException {
|
||||
final Collection<AccountExternalId> r = new ArrayList<AccountExternalId>(1);
|
||||
final Collection<AccountExternalId> r = new ArrayList<>(1);
|
||||
for (AccountExternalId i : db.accountExternalIds().byAccount(
|
||||
user.getAccountId())) {
|
||||
if (i.isScheme(SCHEME_USERNAME)) {
|
||||
|
@@ -83,7 +83,7 @@ public class GroupDetailFactory implements Callable<GroupDetail> {
|
||||
}
|
||||
|
||||
private List<AccountGroupMember> loadMembers() throws OrmException {
|
||||
List<AccountGroupMember> members = new ArrayList<AccountGroupMember>();
|
||||
List<AccountGroupMember> members = new ArrayList<>();
|
||||
for (final AccountGroupMember m : db.accountGroupMembers().byGroup(groupId)) {
|
||||
if (control.canSeeMember(m.getAccountId())) {
|
||||
aic.want(m.getAccountId());
|
||||
@@ -117,7 +117,7 @@ public class GroupDetailFactory implements Callable<GroupDetail> {
|
||||
}
|
||||
|
||||
private List<AccountGroupById> loadIncludes() throws OrmException {
|
||||
List<AccountGroupById> groups = new ArrayList<AccountGroupById>();
|
||||
List<AccountGroupById> groups = new ArrayList<>();
|
||||
|
||||
for (final AccountGroupById m : db.accountGroupById().byGroup(groupId)) {
|
||||
if (control.canSeeGroup(m.getIncludeUUID())) {
|
||||
|
@@ -91,7 +91,7 @@ public class GroupMembers {
|
||||
projectControl.controlFor(project, currentUser).getProjectState()
|
||||
.getOwners();
|
||||
|
||||
final HashSet<Account> projectOwners = new HashSet<Account>();
|
||||
final HashSet<Account> projectOwners = new HashSet<>();
|
||||
for (final AccountGroup.UUID ownerGroup : ownerGroups) {
|
||||
if (!seen.contains(ownerGroup)) {
|
||||
projectOwners.addAll(listAccounts(ownerGroup, project, seen));
|
||||
@@ -107,7 +107,7 @@ public class GroupMembers {
|
||||
final GroupDetail groupDetail =
|
||||
groupDetailFactory.create(group.getId()).call();
|
||||
|
||||
final Set<Account> members = new HashSet<Account>();
|
||||
final Set<Account> members = new HashSet<>();
|
||||
if (groupDetail.members != null) {
|
||||
for (final AccountGroupMember member : groupDetail.members) {
|
||||
members.add(accountCache.get(member.getAccountId()).getAccount());
|
||||
|
@@ -126,10 +126,8 @@ public class PerformCreateGroup {
|
||||
|
||||
private void addMembers(final AccountGroup.Id groupId,
|
||||
final Collection<? extends Account.Id> members) throws OrmException {
|
||||
final List<AccountGroupMember> memberships =
|
||||
new ArrayList<AccountGroupMember>();
|
||||
final List<AccountGroupMemberAudit> membershipsAudit =
|
||||
new ArrayList<AccountGroupMemberAudit>();
|
||||
List<AccountGroupMember> memberships = new ArrayList<>();
|
||||
List<AccountGroupMemberAudit> membershipsAudit = new ArrayList<>();
|
||||
for (Account.Id accountId : members) {
|
||||
final AccountGroupMember membership =
|
||||
new AccountGroupMember(new AccountGroupMember.Key(accountId, groupId));
|
||||
@@ -149,10 +147,8 @@ public class PerformCreateGroup {
|
||||
|
||||
private void addGroups(final AccountGroup.Id groupId,
|
||||
final Collection<? extends AccountGroup.UUID> groups) throws OrmException {
|
||||
final List<AccountGroupById> includeList =
|
||||
new ArrayList<AccountGroupById>();
|
||||
final List<AccountGroupByIdAud> includesAudit =
|
||||
new ArrayList<AccountGroupByIdAud>();
|
||||
List<AccountGroupById> includeList = new ArrayList<>();
|
||||
List<AccountGroupByIdAud> includesAudit = new ArrayList<>();
|
||||
for (AccountGroup.UUID includeUUID : groups) {
|
||||
final AccountGroupById groupInclude =
|
||||
new AccountGroupById(new AccountGroupById.Key(groupId, includeUUID));
|
||||
|
@@ -169,10 +169,10 @@ import javax.security.auth.login.LoginException;
|
||||
LdapQuery.Result findAccount(final Helper.LdapSchema schema,
|
||||
final DirContext ctx, final String username) throws NamingException,
|
||||
AccountException {
|
||||
final HashMap<String, String> params = new HashMap<String, String>();
|
||||
final HashMap<String, String> params = new HashMap<>();
|
||||
params.put(LdapRealm.USERNAME, username);
|
||||
|
||||
final List<LdapQuery.Result> res = new ArrayList<LdapQuery.Result>();
|
||||
final List<LdapQuery.Result> res = new ArrayList<>();
|
||||
for (LdapQuery accountQuery : schema.accountQueryList) {
|
||||
res.addAll(accountQuery.query(ctx, params));
|
||||
}
|
||||
@@ -193,10 +193,10 @@ import javax.security.auth.login.LoginException;
|
||||
final String username, LdapQuery.Result account)
|
||||
throws NamingException, AccountException {
|
||||
final LdapSchema schema = getSchema(ctx);
|
||||
final Set<String> groupDNs = new HashSet<String>();
|
||||
final Set<String> groupDNs = new HashSet<>();
|
||||
|
||||
if (!schema.groupMemberQueryList.isEmpty()) {
|
||||
final HashMap<String, String> params = new HashMap<String, String>();
|
||||
final HashMap<String, String> params = new HashMap<>();
|
||||
|
||||
if (account == null) {
|
||||
try {
|
||||
@@ -244,7 +244,7 @@ import javax.security.auth.login.LoginException;
|
||||
}
|
||||
}
|
||||
|
||||
final Set<AccountGroup.UUID> actual = new HashSet<AccountGroup.UUID>();
|
||||
final Set<AccountGroup.UUID> actual = new HashSet<>();
|
||||
for (String dn : groupDNs) {
|
||||
actual.add(new AccountGroup.UUID(LDAP_UUID + dn));
|
||||
}
|
||||
@@ -305,10 +305,10 @@ import javax.security.auth.login.LoginException;
|
||||
|
||||
LdapSchema(final DirContext ctx) {
|
||||
type = discoverLdapType(ctx);
|
||||
groupMemberQueryList = new ArrayList<LdapQuery>();
|
||||
accountQueryList = new ArrayList<LdapQuery>();
|
||||
groupMemberQueryList = new ArrayList<>();
|
||||
accountQueryList = new ArrayList<>();
|
||||
|
||||
final Set<String> accountAtts = new HashSet<String>();
|
||||
final Set<String> accountAtts = new HashSet<>();
|
||||
|
||||
// Group query
|
||||
//
|
||||
|
@@ -227,7 +227,7 @@ public class LdapGroupBackend implements GroupBackend {
|
||||
ParameterizedString filter = ParameterizedString.asis(
|
||||
schema.groupPattern.replace(GROUPNAME, name).toString());
|
||||
Set<String> returnAttrs =
|
||||
new HashSet<String>(schema.groupName.getParameterNames());
|
||||
new HashSet<>(schema.groupName.getParameterNames());
|
||||
Map<String, String> params = Collections.emptyMap();
|
||||
for (String groupBase : schema.groupBases) {
|
||||
LdapQuery query = new LdapQuery(
|
||||
|
@@ -69,7 +69,7 @@ class LdapQuery {
|
||||
sc.setReturningAttributes(returnAttributes);
|
||||
res = ctx.search(base, pattern.getRawPattern(), pattern.bind(params), sc);
|
||||
try {
|
||||
final List<Result> r = new ArrayList<Result>();
|
||||
final List<Result> r = new ArrayList<>();
|
||||
try {
|
||||
while (res.hasMore()) {
|
||||
r.add(new Result(res.next()));
|
||||
@@ -83,7 +83,7 @@ class LdapQuery {
|
||||
}
|
||||
|
||||
class Result {
|
||||
private final Map<String, Attribute> atts = new HashMap<String, Attribute>();
|
||||
private final Map<String, Attribute> atts = new HashMap<>();
|
||||
|
||||
Result(final SearchResult sr) {
|
||||
if (returnAttributes != null) {
|
||||
|
@@ -88,7 +88,7 @@ public class LdapRealm implements Realm {
|
||||
this.membershipCache = membershipCache;
|
||||
this.config = config;
|
||||
|
||||
this.readOnlyAccountFields = new HashSet<Account.FieldName>();
|
||||
this.readOnlyAccountFields = new HashSet<>();
|
||||
|
||||
if (optdef(config, "accountFullName", "DEFAULT") != null) {
|
||||
readOnlyAccountFields.add(Account.FieldName.FULL_NAME);
|
||||
@@ -174,7 +174,7 @@ public class LdapRealm implements Realm {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Map<String, String> values = new HashMap<String, String>();
|
||||
final Map<String, String> values = new HashMap<>();
|
||||
for (final String name : m.attributes()) {
|
||||
values.put(name, m.get(name));
|
||||
}
|
||||
|
@@ -83,8 +83,7 @@ public abstract class CacheModule extends AbstractModule {
|
||||
@SuppressWarnings("unchecked")
|
||||
Key<Cache<K, V>> key = (Key<Cache<K, V>>) Key.get(type, Names.named(name));
|
||||
|
||||
CacheProvider<K, V> m =
|
||||
new CacheProvider<K, V>(this, name, keyType, valType);
|
||||
CacheProvider<K, V> m = new CacheProvider<>(this, name, keyType, valType);
|
||||
bind(key).toProvider(m).asEagerSingleton();
|
||||
bind(ANY_CACHE).annotatedWith(Exports.named(name)).to(key);
|
||||
return m.maximumWeight(1024);
|
||||
|
@@ -441,8 +441,7 @@ public class ChangeJson {
|
||||
private Map<String, LabelInfo> initLabels(ChangeData cd,
|
||||
LabelTypes labelTypes, boolean standard) throws OrmException {
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
Map<String, LabelInfo> labels =
|
||||
new TreeMap<String, LabelInfo>(labelTypes.nameComparator());
|
||||
Map<String, LabelInfo> labels = new TreeMap<>(labelTypes.nameComparator());
|
||||
for (SubmitRecord rec : submitRecords(cd)) {
|
||||
if (rec.labels == null) {
|
||||
continue;
|
||||
@@ -572,8 +571,7 @@ public class ChangeJson {
|
||||
// would have done. These should really come from a stored submit record.
|
||||
//
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
Map<String, LabelInfo> labels =
|
||||
new TreeMap<String, LabelInfo>(labelTypes.nameComparator());
|
||||
Map<String, LabelInfo> labels = new TreeMap<>(labelTypes.nameComparator());
|
||||
for (String name : labelNames) {
|
||||
LabelType type = labelTypes.byLabel(name);
|
||||
LabelInfo li = new LabelInfo();
|
||||
|
@@ -90,7 +90,7 @@ public class ReviewerJson {
|
||||
LabelTypes labelTypes = ctl.getLabelTypes();
|
||||
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
out.approvals = new TreeMap<String,String>(labelTypes.nameComparator());
|
||||
out.approvals = new TreeMap<>(labelTypes.nameComparator());
|
||||
for (PatchSetApproval ca : approvals) {
|
||||
for (PermissionRange pr : ctl.getLabelRanges()) {
|
||||
if (!pr.isEmpty()) {
|
||||
|
@@ -112,7 +112,7 @@ public class AuthConfig {
|
||||
s = new String[] {"http://", "https://"};
|
||||
}
|
||||
|
||||
List<OpenIdProviderPattern> r = new ArrayList<OpenIdProviderPattern>();
|
||||
List<OpenIdProviderPattern> r = new ArrayList<>();
|
||||
for (String pattern : s) {
|
||||
r.add(OpenIdProviderPattern.create(pattern));
|
||||
}
|
||||
|
@@ -165,7 +165,7 @@ public class ConfigUtil {
|
||||
public static <T extends Enum<?>> List<T> getEnumList(final Config config,
|
||||
final String section, final String subsection, final String setting,
|
||||
final T[] all, final T defaultValue) {
|
||||
final List<T> list = new ArrayList<T>();
|
||||
final List<T> list = new ArrayList<>();
|
||||
final String[] values = config.getStringList(section, subsection, setting);
|
||||
if (values.length == 0) {
|
||||
list.add(defaultValue);
|
||||
|
@@ -40,13 +40,13 @@ public class DownloadConfig {
|
||||
ConfigUtil.getEnumList(cfg, "download", null, "scheme",
|
||||
DownloadScheme.DEFAULT_DOWNLOADS);
|
||||
downloadSchemes =
|
||||
Collections.unmodifiableSet(new HashSet<DownloadScheme>(allSchemes));
|
||||
Collections.unmodifiableSet(new HashSet<>(allSchemes));
|
||||
|
||||
List<DownloadCommand> allCommands =
|
||||
ConfigUtil.getEnumList(cfg, "download", null, "command",
|
||||
DownloadCommand.DEFAULT_DOWNLOADS);
|
||||
downloadCommands =
|
||||
Collections.unmodifiableSet(new HashSet<DownloadCommand>(allCommands));
|
||||
Collections.unmodifiableSet(new HashSet<>(allCommands));
|
||||
}
|
||||
|
||||
/** Scheme used to download. */
|
||||
|
@@ -34,8 +34,7 @@ public class TrackingFootersProvider implements Provider<TrackingFooters> {
|
||||
private static String FOOTER_TAG = "footer";
|
||||
private static String SYSTEM_TAG = "system";
|
||||
private static String REGEX_TAG = "match";
|
||||
private final List<TrackingFooter> trackingFooters =
|
||||
new ArrayList<TrackingFooter>();
|
||||
private final List<TrackingFooter> trackingFooters = new ArrayList<>();
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(TrackingFootersProvider.class);
|
||||
|
||||
|
@@ -190,7 +190,7 @@ public class EventFactory {
|
||||
*/
|
||||
public void addSubmitRecords(ChangeAttribute ca,
|
||||
List<SubmitRecord> submitRecords) {
|
||||
ca.submitRecords = new ArrayList<SubmitRecordAttribute>();
|
||||
ca.submitRecords = new ArrayList<>();
|
||||
|
||||
for (SubmitRecord submitRecord : submitRecords) {
|
||||
SubmitRecordAttribute sa = new SubmitRecordAttribute();
|
||||
@@ -209,7 +209,7 @@ public class EventFactory {
|
||||
private void addSubmitRecordLabels(SubmitRecord submitRecord,
|
||||
SubmitRecordAttribute sa) {
|
||||
if (submitRecord.labels != null && !submitRecord.labels.isEmpty()) {
|
||||
sa.labels = new ArrayList<SubmitLabelAttribute>();
|
||||
sa.labels = new ArrayList<>();
|
||||
for (SubmitRecord.Label lbl : submitRecord.labels) {
|
||||
SubmitLabelAttribute la = new SubmitLabelAttribute();
|
||||
la.label = lbl.label;
|
||||
@@ -224,8 +224,8 @@ public class EventFactory {
|
||||
}
|
||||
|
||||
public void addDependencies(ChangeAttribute ca, Change change) {
|
||||
ca.dependsOn = new ArrayList<DependencyAttribute>();
|
||||
ca.neededBy = new ArrayList<DependencyAttribute>();
|
||||
ca.dependsOn = new ArrayList<>();
|
||||
ca.neededBy = new ArrayList<>();
|
||||
try {
|
||||
final ReviewDb db = schema.open();
|
||||
try {
|
||||
@@ -293,7 +293,7 @@ public class EventFactory {
|
||||
|
||||
public void addTrackingIds(ChangeAttribute a, Multimap<String, String> set) {
|
||||
if (!set.isEmpty()) {
|
||||
a.trackingIds = new ArrayList<TrackingIdAttribute>(set.size());
|
||||
a.trackingIds = new ArrayList<>(set.size());
|
||||
for (Map.Entry<String, Collection<String>> e : set.asMap().entrySet()) {
|
||||
for (String id : e.getValue()) {
|
||||
TrackingIdAttribute t = new TrackingIdAttribute();
|
||||
@@ -324,7 +324,7 @@ public class EventFactory {
|
||||
Map<PatchSet.Id, Collection<PatchSetApproval>> approvals,
|
||||
boolean includeFiles, Change change, LabelTypes labelTypes) {
|
||||
if (!ps.isEmpty()) {
|
||||
ca.patchSets = new ArrayList<PatchSetAttribute>(ps.size());
|
||||
ca.patchSets = new ArrayList<>(ps.size());
|
||||
for (PatchSet p : ps) {
|
||||
PatchSetAttribute psa = asPatchSetAttribute(p);
|
||||
if (approvals != null) {
|
||||
@@ -344,8 +344,7 @@ public class EventFactory {
|
||||
if (comment.getKey().getParentKey().getParentKey().get()
|
||||
== Integer.parseInt(patchSetAttribute.number)) {
|
||||
if (patchSetAttribute.comments == null) {
|
||||
patchSetAttribute.comments =
|
||||
new ArrayList<PatchSetCommentAttribute>();
|
||||
patchSetAttribute.comments = new ArrayList<>();
|
||||
}
|
||||
patchSetAttribute.comments.add(asPatchSetLineAttribute(comment));
|
||||
}
|
||||
@@ -358,7 +357,7 @@ public class EventFactory {
|
||||
PatchList patchList = patchListCache.get(change, patchSet);
|
||||
for (PatchListEntry patch : patchList.getPatches()) {
|
||||
if (patchSetAttribute.files == null) {
|
||||
patchSetAttribute.files = new ArrayList<PatchAttribute>();
|
||||
patchSetAttribute.files = new ArrayList<>();
|
||||
}
|
||||
|
||||
PatchAttribute p = new PatchAttribute();
|
||||
@@ -376,7 +375,7 @@ public class EventFactory {
|
||||
public void addComments(ChangeAttribute ca,
|
||||
Collection<ChangeMessage> messages) {
|
||||
if (!messages.isEmpty()) {
|
||||
ca.comments = new ArrayList<MessageAttribute>();
|
||||
ca.comments = new ArrayList<>();
|
||||
for (ChangeMessage message : messages) {
|
||||
ca.comments.add(asMessageAttribute(message));
|
||||
}
|
||||
@@ -402,7 +401,7 @@ public class EventFactory {
|
||||
try {
|
||||
final ReviewDb db = schema.open();
|
||||
try {
|
||||
p.parents = new ArrayList<String>();
|
||||
p.parents = new ArrayList<>();
|
||||
for (PatchSetAncestor a : db.patchSetAncestors().ancestorsOf(
|
||||
patchSet.getId())) {
|
||||
p.parents.add(a.getAncestorRevision().get());
|
||||
@@ -452,7 +451,7 @@ public class EventFactory {
|
||||
public void addApprovals(PatchSetAttribute p,
|
||||
Collection<PatchSetApproval> list, LabelTypes labelTypes) {
|
||||
if (!list.isEmpty()) {
|
||||
p.approvals = new ArrayList<ApprovalAttribute>(list.size());
|
||||
p.approvals = new ArrayList<>(list.size());
|
||||
for (PatchSetApproval a : list) {
|
||||
if (a.getValue() != 0) {
|
||||
p.approvals.add(asApprovalAttribute(a, labelTypes));
|
||||
|
@@ -24,7 +24,7 @@ public class AccountsSection {
|
||||
|
||||
public List<PermissionRule> getSameGroupVisibility() {
|
||||
if (sameGroupVisibility == null) {
|
||||
sameGroupVisibility = new ArrayList<PermissionRule>();
|
||||
sameGroupVisibility = new ArrayList<>();
|
||||
}
|
||||
return sameGroupVisibility;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user