Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Copyright (C) 2012 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.registration;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.inject.Binding;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** DO NOT USE */
public class PrivateInternals_DynamicTypes {
public static Map, DynamicItem> dynamicItemsOf(Injector src) {
Map, DynamicItem> m = new HashMap<>();
for (Map.Entry, Binding> e : src.getBindings().entrySet()) {
TypeLiteral type = e.getKey().getTypeLiteral();
if (type.getRawType() == DynamicItem.class) {
ParameterizedType p = (ParameterizedType) type.getType();
m.put(
TypeLiteral.get(p.getActualTypeArguments()[0]),
(DynamicItem) e.getValue().getProvider().get());
}
}
if (m.isEmpty()) {
return Collections.emptyMap();
}
return Collections.unmodifiableMap(m);
}
public static Map, DynamicSet> dynamicSetsOf(Injector src) {
Map, DynamicSet> m = new HashMap<>();
for (Map.Entry, Binding> e : src.getBindings().entrySet()) {
TypeLiteral type = e.getKey().getTypeLiteral();
if (type.getRawType() == DynamicSet.class) {
ParameterizedType p = (ParameterizedType) type.getType();
m.put(
TypeLiteral.get(p.getActualTypeArguments()[0]),
(DynamicSet) e.getValue().getProvider().get());
}
}
if (m.isEmpty()) {
return Collections.emptyMap();
}
return Collections.unmodifiableMap(m);
}
public static Map, DynamicMap> dynamicMapsOf(Injector src) {
Map, DynamicMap> m = new HashMap<>();
for (Map.Entry, Binding> e : src.getBindings().entrySet()) {
TypeLiteral type = e.getKey().getTypeLiteral();
if (type.getRawType() == DynamicMap.class) {
ParameterizedType p = (ParameterizedType) type.getType();
m.put(
TypeLiteral.get(p.getActualTypeArguments()[0]),
(DynamicMap) e.getValue().getProvider().get());
}
}
if (m.isEmpty()) {
return Collections.emptyMap();
}
return Collections.unmodifiableMap(m);
}
public static List attachItems(
Injector src, String pluginName, Map, DynamicItem> items) {
if (src == null || items == null || items.isEmpty()) {
return Collections.emptyList();
}
List handles = new ArrayList<>(4);
try {
for (Map.Entry, DynamicItem> e : items.entrySet()) {
@SuppressWarnings("unchecked")
TypeLiteral