@Nonnull @Override public Set<? extends Field> getFields() {
return new AbstractSet<Field>() {
@Nonnull @Override public Iterator<Field> iterator() {
return Iterators.transform(Iterators.forArray(cls.getDeclaredFields()),
new Function<java.lang.reflect.Field, Field>() {
@Nullable @Override public Field apply(@Nullable java.lang.reflect.Field input) {
return new ReflectionField(input);
}
});
}
@Override public int size() {
return cls.getDeclaredFields().length;
}
};
}
java类com.google.common.collect.Iterators的实例源码
ReflectionClassDef.java 文件源码
项目:andbg
阅读 39
收藏 0
点赞 0
评论 0
ExternalSortBatch.java 文件源码
项目:QDrill
阅读 44
收藏 0
点赞 0
评论 0
public ExternalSortBatch(ExternalSort popConfig, FragmentContext context, RecordBatch incoming) throws OutOfMemoryException {
super(popConfig, context, true);
this.incoming = incoming;
DrillConfig config = context.getConfig();
Configuration conf = new Configuration();
conf.set("fs.default.name", config.getString(ExecConstants.EXTERNAL_SORT_SPILL_FILESYSTEM));
try {
this.fs = FileSystem.get(conf);
} catch (IOException e) {
throw new RuntimeException(e);
}
SPILL_BATCH_GROUP_SIZE = config.getInt(ExecConstants.EXTERNAL_SORT_SPILL_GROUP_SIZE);
SPILL_THRESHOLD = config.getInt(ExecConstants.EXTERNAL_SORT_SPILL_THRESHOLD);
dirs = Iterators.cycle(config.getStringList(ExecConstants.EXTERNAL_SORT_SPILL_DIRS));
copierAllocator = oContext.getAllocator().getChildAllocator(
context, PriorityQueueCopier.INITIAL_ALLOCATION, PriorityQueueCopier.MAX_ALLOCATION, true);
FragmentHandle handle = context.getHandle();
fileName = String.format("%s/major_fragment_%s/minor_fragment_%s/operator_%s", QueryIdHelper.getQueryId(handle.getQueryId()),
handle.getMajorFragmentId(), handle.getMinorFragmentId(), popConfig.getOperatorId());
}
DefaultTaskOutputs.java 文件源码
项目:Reer
阅读 32
收藏 0
点赞 0
评论 0
@Override
public SortedSet<TaskOutputFilePropertySpec> getFileProperties() {
if (fileProperties == null) {
TaskPropertyUtils.ensurePropertiesHaveNames(filePropertiesInternal);
Iterator<TaskOutputFilePropertySpec> flattenedProperties = Iterators.concat(Iterables.transform(filePropertiesInternal, new Function<TaskPropertySpec, Iterator<? extends TaskOutputFilePropertySpec>>() {
@Override
public Iterator<? extends TaskOutputFilePropertySpec> apply(TaskPropertySpec propertySpec) {
if (propertySpec instanceof CompositeTaskOutputPropertySpec) {
return ((CompositeTaskOutputPropertySpec) propertySpec).resolveToOutputProperties();
} else {
return Iterators.singletonIterator((TaskOutputFilePropertySpec) propertySpec);
}
}
}).iterator());
fileProperties = TaskPropertyUtils.collectFileProperties("output", flattenedProperties);
}
return fileProperties;
}
HashClassPathSnapshotter.java 文件源码
项目:Reer
阅读 47
收藏 0
点赞 0
评论 0
private void hash(com.google.common.hash.Hasher combinedHash, List<String> visitedFilePaths, Set<File> visitedDirs, Iterator<File> toHash) {
while (toHash.hasNext()) {
File file = FileUtils.canonicalize(toHash.next());
if (file.isDirectory()) {
if (visitedDirs.add(file)) {
//in theory, awkward symbolic links can lead to recursion problems.
//TODO - figure out a way to test it. I only tested it 'manually' and the feature is needed.
File[] sortedFiles = file.listFiles();
Arrays.sort(sortedFiles);
hash(combinedHash, visitedFilePaths, visitedDirs, Iterators.forArray(sortedFiles));
}
} else if (file.isFile()) {
visitedFilePaths.add(file.getAbsolutePath());
combinedHash.putBytes(hasher.hash(file).asBytes());
}
//else an empty folder - a legit situation
}
}
ExceptionAnalyser.java 文件源码
项目:n4js
阅读 34
收藏 0
点赞 0
评论 0
@Override
protected List<Diagnostic> getScriptErrors(Script script) {
EcoreUtil.resolveAll(script.eResource());
List<Diagnostic> diagnostics = super.getScriptErrors(script);
Iterator<Expression> expressions = Iterators.filter(EcoreUtil2.eAll(script), Expression.class);
List<Diagnostic> result = Lists.<Diagnostic> newArrayList(Iterables.filter(diagnostics,
ExceptionDiagnostic.class));
while (expressions.hasNext()) {
Expression expression = expressions.next();
RuleEnvironment ruleEnvironment = RuleEnvironmentExtensions.newRuleEnvironment(expression);
Result<TypeRef> type = typeSystem.type(ruleEnvironment, expression);
if (type.getRuleFailedException() != null) {
Throwable cause = Throwables.getRootCause(type.getRuleFailedException());
if (!(cause instanceof RuleFailedException)) {
if (cause instanceof Exception) {
result.add(new ExceptionDiagnostic((Exception) cause));
} else {
throw new RuntimeException(cause);
}
}
}
}
validator.validate(script.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
return result;
}
CsvDataSource.java 文件源码
项目:tableschema-java
阅读 37
收藏 0
点赞 0
评论 0
@Override
public Iterator<String[]> iterator() throws Exception{
Iterator<CSVRecord> iterCSVRecords = this.getCSVParser().iterator();
Iterator<String[]> iterStringArrays = Iterators.transform(iterCSVRecords, (CSVRecord input) -> {
Iterator<String> iterCols = input.iterator();
List<String> cols = new ArrayList();
while(iterCols.hasNext()){
cols.add(iterCols.next());
}
String[] output = cols.toArray(new String[0]);
return output;
});
return iterStringArrays;
}
PlayerProfileCache.java 文件源码
项目:BaseClient
阅读 48
收藏 0
点赞 0
评论 0
private List<PlayerProfileCache.ProfileEntry> getEntriesWithLimit(int limitSize)
{
ArrayList<PlayerProfileCache.ProfileEntry> arraylist = Lists.<PlayerProfileCache.ProfileEntry>newArrayList();
for (GameProfile gameprofile : Lists.newArrayList(Iterators.limit(this.gameProfiles.iterator(), limitSize)))
{
PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = this.getByUUID(gameprofile.getId());
if (playerprofilecache$profileentry != null)
{
arraylist.add(playerprofilecache$profileentry);
}
}
return arraylist;
}
SkinDownloader.java 文件源码
项目:libtrails
阅读 43
收藏 0
点赞 0
评论 0
public String getSkinUrl(GameProfile prof) throws ParseException {
Collection<Property> ps = prof.getProperties().get("textures");
if (ps == null || ps.isEmpty()) {
return null;
} else {
Property p = Iterators.getLast(ps.iterator());
JSONObject obj = (JSONObject) new JSONParser().parse(
new String(Base64.getDecoder().decode(p.getValue())));
obj = ((JSONObject) obj.get("textures"));
obj = ((JSONObject) obj.get("SKIN"));
return (String) obj.get("url");
}
}
SubscriberRegistry.java 文件源码
项目:guava-mock
阅读 59
收藏 0
点赞 0
评论 0
/**
* Gets an iterator representing an immutable snapshot of all subscribers to the given event at
* the time this method is called.
*/
Iterator<Subscriber> getSubscribers(Object event) {
ImmutableSet<Class<?>> eventTypes = flattenHierarchy(event.getClass());
List<Iterator<Subscriber>> subscriberIterators =
Lists.newArrayListWithCapacity(eventTypes.size());
for (Class<?> eventType : eventTypes) {
CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);
if (eventSubscribers != null) {
// eager no-copy snapshot
subscriberIterators.add(eventSubscribers.iterator());
}
}
return Iterators.concat(subscriberIterators.iterator());
}
BinderImpl.java 文件源码
项目:dremio-oss
阅读 44
收藏 0
点赞 0
评论 0
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Iterator<Binding<?>> iterator() {
return Iterators.transform(lookups.entrySet().iterator(), new Function<Entry<Class<?>, Resolver>, Binding<?>>(){
@Override
public Binding apply(Entry<Class<?>, Resolver> input) {
switch(input.getValue().getType()){
case INSTANCE:
return new InstanceBinding(input.getKey(), ((InjectableReference)input.getValue()).clazz);
case SINGLETON:
return new SingletonBinding(input.getKey(), input.getValue().get(null));
default:
throw new IllegalStateException();
}
}});
}
SubscriberRegistryTest.java 文件源码
项目:googles-monorepo-demo
阅读 37
收藏 0
点赞 0
评论 0
public void testGetSubscribers() {
assertEquals(0, Iterators.size(registry.getSubscribers("")));
registry.register(new StringSubscriber());
assertEquals(1, Iterators.size(registry.getSubscribers("")));
registry.register(new StringSubscriber());
assertEquals(2, Iterators.size(registry.getSubscribers("")));
registry.register(new ObjectSubscriber());
assertEquals(3, Iterators.size(registry.getSubscribers("")));
assertEquals(1, Iterators.size(registry.getSubscribers(new Object())));
assertEquals(1, Iterators.size(registry.getSubscribers(1)));
registry.register(new IntegerSubscriber());
assertEquals(3, Iterators.size(registry.getSubscribers("")));
assertEquals(1, Iterators.size(registry.getSubscribers(new Object())));
assertEquals(2, Iterators.size(registry.getSubscribers(1)));
}
PreYggdrasilConverter.java 文件源码
项目:Backmemed
阅读 67
收藏 0
点赞 0
评论 0
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
{
public boolean apply(@Nullable String p_apply_1_)
{
return !StringUtils.isNullOrEmpty(p_apply_1_);
}
}), String.class);
if (server.isServerInOnlineMode())
{
server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
}
else
{
for (String s : astring)
{
UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
GameProfile gameprofile = new GameProfile(uuid, s);
callback.onProfileLookupSucceeded(gameprofile);
}
}
}
OptionIterator.java 文件源码
项目:QDrill
阅读 41
收藏 0
点赞 0
评论 0
public OptionIterator(FragmentContext context, Mode mode){
final DrillConfigIterator configOptions = new DrillConfigIterator(context.getConfig());
fragmentOptions = context.getOptions();
final Iterator<OptionValue> optionList;
switch(mode){
case BOOT:
optionList = configOptions.iterator();
break;
case SYS_SESS:
optionList = fragmentOptions.iterator();
break;
default:
optionList = Iterators.concat(configOptions.iterator(), fragmentOptions.iterator());
}
List<OptionValue> values = Lists.newArrayList(optionList);
Collections.sort(values);
mergedOptions = values.iterator();
}
PlayerProfileCache.java 文件源码
项目:BaseClient
阅读 40
收藏 0
点赞 0
评论 0
private List<PlayerProfileCache.ProfileEntry> getEntriesWithLimit(int limitSize)
{
ArrayList<PlayerProfileCache.ProfileEntry> arraylist = Lists.<PlayerProfileCache.ProfileEntry>newArrayList();
for (GameProfile gameprofile : Lists.newArrayList(Iterators.limit(this.gameProfiles.iterator(), limitSize)))
{
PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = this.getByUUID(gameprofile.getId());
if (playerprofilecache$profileentry != null)
{
arraylist.add(playerprofilecache$profileentry);
}
}
return arraylist;
}
PlayerProfileCache.java 文件源码
项目:DecompiledMinecraft
阅读 39
收藏 0
点赞 0
评论 0
private List<PlayerProfileCache.ProfileEntry> getEntriesWithLimit(int limitSize)
{
ArrayList<PlayerProfileCache.ProfileEntry> arraylist = Lists.<PlayerProfileCache.ProfileEntry>newArrayList();
for (GameProfile gameprofile : Lists.newArrayList(Iterators.limit(this.gameProfiles.iterator(), limitSize)))
{
PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = this.getByUUID(gameprofile.getId());
if (playerprofilecache$profileentry != null)
{
arraylist.add(playerprofilecache$profileentry);
}
}
return arraylist;
}
VeinCapTransformer.java 文件源码
项目:anvil
阅读 41
收藏 0
点赞 0
评论 0
@Override
public void transform(ClassNode clazz, MethodNode method, InsnMatcher matcher) {
AbstractInsnNode[] match = Iterators.getOnlyElement(matcher.match("BIPUSH ISTORE", m -> {
IntInsnNode push = (IntInsnNode) m[0];
if (push.operand != 50) {
return false;
}
VarInsnNode store = (VarInsnNode) m[1];
LocalVariableNode node = AsmUtils.getLocalVariable(method, store.var, store);
return node != null && node.name.equals("resource") && node.desc.equals("I");
}));
method.instructions.remove(match[0]);
method.instructions.remove(match[1]);
}
TreeIterator.java 文件源码
项目:bazel-buildfarm
阅读 30
收藏 0
点赞 0
评论 0
@Override
public Directory next() throws NoSuchElementException {
Iterator<Digest> iter = pointers.peek();
if (!iter.hasNext()) {
throw new NoSuchElementException();
}
/* we can have null directories in our list
* if members of the tree have been removed from
* the cas. we return this to retain the information
* (and simplify the interface) that they have been
* removed. */
Digest digest = iter.next();
Directory directory = expectDirectory(instance.getBlob(digest));
if (directory != null) {
/* the path to a new iter set is the path to its parent */
parentPath.addLast(digest);
path = parentPath.clone();
pointers.push(Iterators.transform(
directory.getDirectoriesList().iterator(),
directoryNode -> directoryNode.getDigest()));
}
advanceIterator();
return directory;
}
ClassDefRewriter.java 文件源码
项目:andbg
阅读 45
收藏 0
点赞 0
评论 0
@Nonnull
@Override
public Iterable<? extends Method> getMethods() {
return new Iterable<Method>() {
@Nonnull
@Override
public Iterator<Method> iterator() {
return Iterators.concat(getDirectMethods().iterator(), getVirtualMethods().iterator());
}
};
}
MutableTypeToInstanceMap.java 文件源码
项目:googles-monorepo-demo
阅读 35
收藏 0
点赞 0
评论 0
private static <K, V> Iterator<Entry<K, V>> transformEntries(Iterator<Entry<K, V>> entries) {
return Iterators.transform(
entries,
new Function<Entry<K, V>, Entry<K, V>>() {
@Override
public Entry<K, V> apply(Entry<K, V> entry) {
return new UnmodifiableEntry<K, V>(entry);
}
});
}
BTreeRow.java 文件源码
项目:sstable-adaptor
阅读 41
收藏 0
点赞 0
评论 0
private CellInLegacyOrderIterator(CFMetaData metadata, boolean reversed)
{
AbstractType<?> nameComparator = metadata.getColumnDefinitionNameComparator(isStatic() ? ColumnDefinition.Kind.STATIC : ColumnDefinition.Kind.REGULAR);
this.comparator = reversed ? Collections.reverseOrder(nameComparator) : nameComparator;
this.reversed = reversed;
// copy btree into array for simple separate iteration of simple and complex columns
this.data = new Object[BTree.size(btree)];
BTree.toArray(btree, data, 0);
int idx = Iterators.indexOf(Iterators.forArray(data), cd -> cd instanceof ComplexColumnData);
this.firstComplexIdx = idx < 0 ? data.length : idx;
this.complexIdx = firstComplexIdx;
}
NodeBackedModelMap.java 文件源码
项目:Reer
阅读 44
收藏 0
点赞 0
评论 0
@Override
public Iterator<T> iterator() {
viewState.assertCanReadChildren();
return Iterators.transform(keySet().iterator(), new Function<String, T>() {
@Override
public T apply(@Nullable String name) {
return get(name);
}
});
}
TestUtil.java 文件源码
项目:googles-monorepo-demo
阅读 37
收藏 0
点赞 0
评论 0
/**
* In some cases our graph implementations return custom sets that define their own size() and
* contains(). Verify that these sets are consistent with the elements of their iterator.
*/
@CanIgnoreReturnValue
static <T> Set<T> sanityCheckSet(Set<T> set) {
assertThat(set).hasSize(Iterators.size(set.iterator()));
for (Object element : set) {
assertThat(set).contains(element);
}
assertThat(set).doesNotContain(new Object());
assertThat(set).isEqualTo(ImmutableSet.copyOf(set));
return set;
}
DiscoveredInputsTaskStateChanges.java 文件源码
项目:Reer
阅读 42
收藏 0
点赞 0
评论 0
@Override
public Iterator<TaskStateChange> iterator() {
if (getPrevious() == null) {
return Iterators.<TaskStateChange>singletonIterator(new DescriptiveChange("Discovered input file history is not available."));
}
return getCurrent().iterateContentChangesSince(getPrevious(), "discovered input");
}
CompositeDomainObjectSet.java 文件源码
项目:Reer
阅读 43
收藏 0
点赞 0
评论 0
@SuppressWarnings({"NullableProblems", "unchecked"})
@Override
public Iterator<T> iterator() {
CompositeCollection store = getStore();
if (store.isEmpty()) {
return Iterators.emptyIterator();
}
return new SetIterator();
}
ClassDefRewriter.java 文件源码
项目:andbg
阅读 44
收藏 0
点赞 0
评论 0
@Nonnull
@Override
public Iterable<? extends Field> getFields() {
return new Iterable<Field>() {
@Nonnull
@Override
public Iterator<Field> iterator() {
return Iterators.concat(getStaticFields().iterator(), getInstanceFields().iterator());
}
};
}
HardVox.java 文件源码
项目:HardVox
阅读 46
收藏 0
点赞 0
评论 0
@EventHandler
public void serverStarting(FMLServerStartingEvent event) {
Iterator<CommandModule> modules = Iterators.forArray(
new RegionCommands(),
new OperationCommands(),
new SessionCommands());
modules.forEachRemaining(m -> m.addCommands(event::registerServerCommand));
}
AbstractCounterGroup.java 文件源码
项目:hadoop
阅读 49
收藏 0
点赞 0
评论 0
@Override
public synchronized boolean equals(Object genericRight) {
if (genericRight instanceof CounterGroupBase<?>) {
@SuppressWarnings("unchecked")
CounterGroupBase<T> right = (CounterGroupBase<T>) genericRight;
return Iterators.elementsEqual(iterator(), right.iterator());
}
return false;
}
VecArg.java 文件源码
项目:HardVox
阅读 56
收藏 0
点赞 0
评论 0
@Override
public Iterator<String> getCompletions(ArgumentContext context) {
String textSoFar = context.text;
List<String> sections = COMMA_SPLITTER.splitToList(textSoFar);
String lastSection = Iterables.getLast(sections);
String prependText = String.join(",", sections.subList(0, sections.size() - 1));
Iterator<String> integer = Iterators.transform(delegate.getCompletions(context.withText(lastSection)), prependText::concat);
if (textSoFar.isEmpty() || textSoFar.endsWith(",") || textSoFar.codePoints().filter(cp -> cp == ',').count() >= (dimensions - 1)) {
return integer;
}
return Iterators.concat(integer, Iterators.transform(COMMA.iterator(), textSoFar::concat));
}
UriContentTreeImpl.java 文件源码
项目:sonar-css-plugin
阅读 44
收藏 0
点赞 0
评论 0
@Override
public Iterator<Tree> childrenIterator() {
if (string != null) {
return Iterators.singletonIterator(string);
} else {
return Iterators.singletonIterator(ident);
}
}
ReadMainDexList.java 文件源码
项目:r8
阅读 38
收藏 0
点赞 0
评论 0
private void run(String[] args) throws Exception {
if (args.length < 1 || args.length > 3) {
System.out.println("Usage: command [-k] <main_dex_list> [<proguard_map>]");
System.exit(0);
}
Iterator<String> arguments = Iterators.forArray(args);
Function<String, String> outputGenerator;
String arg = arguments.next();
if (arg.equals("-k")) {
outputGenerator = this::toKeepRule;
arg = arguments.next();
} else {
outputGenerator = this::toClassFilePath;
}
Path mainDexList = Paths.get(arg);
final ClassNameMapper mapper =
arguments.hasNext() ? ProguardMapReader.mapperFromFile(Paths.get(arguments.next())) : null;
FileUtils.readTextFile(mainDexList)
.stream()
.map(this::stripDotClass)
.map(name -> name.replace('/', '.'))
.map(name -> deobfuscateClassName(name, mapper))
.map(outputGenerator)
.sorted()
.collect(Collectors.toList())
.forEach(System.out::println);
}