Java Code Examples for com.google.common.collect.Iterables

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project agorava-core, under directory /agorava-core-impl-cdi/src/main/java/org/agorava/core/cdi/.

Source file: AgoravaExtension.java

  19 
vote

/** 
 * After all  {@link SocialMediaApiHub} were discovered we get there bean to retrieve the actual name of Social Mediaand associates it with the corresponding Qualifier
 * @param adv
 * @param beanManager
 */
public void processAfterDeploymentValidation(@Observes AfterDeploymentValidation adv,BeanManager beanManager){
  CreationalContext ctx=beanManager.createCreationalContext(null);
  for (  Annotation qual : servicesQualifiersAvailable) {
    Bean beanSoc=Iterables.getLast(beanManager.getBeans(SocialMediaApiHub.class,qual));
    SocialMediaApiHub smah=(SocialMediaApiHub)beanManager.getReference(beanSoc,beanSoc.getBeanClass(),ctx);
    String name=smah.getSocialMediaName();
    if (servicesToQualifier.containsKey(name) && !servicesToQualifier.get(name).equals(qual)) {
      throw new AgoravaException("This social media name : " + name + " is already registered with another qualifier. Check your modules or you SocialMediaApiHub producers.");
    }
    servicesToQualifier.put(name,qual);
  }
  ctx.release();
  for (  Annotation annot : servicesQualifiersConfigured) {
    servicesNames.add(servicesToQualifier.inverse().get(annot));
  }
  log.info("Agorava initialization complete");
}
 

Example 2

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/.

Source file: SessionsActivity.java

  19 
vote

private void refreshSensors(){
  List<Sensor> sensors=sensorRepository.getAll();
  Iterable<SensorWrapper> wrappers=Iterables.transform(sensors,new Function<Sensor,SensorWrapper>(){
    @Override public SensorWrapper apply(    @Nullable Sensor input){
      return new SensorWrapper(input);
    }
  }
);
  List<SensorWrapper> wrapperList=newArrayList(wrappers);
  sensorAdapter.update(wrapperList);
  sensorSpinner.setPromptId(R.string.select_sensor);
  sensorSpinner.setOnItemSelectedListener(this);
}
 

Example 3

From project airlift, under directory /discovery/src/main/java/io/airlift/discovery/client/.

Source file: ServiceInventory.java

  19 
vote

public Iterable<ServiceDescriptor> getServiceDescriptors(final String type){
  return Iterables.filter(getServiceDescriptors(),new Predicate<ServiceDescriptor>(){
    @Override public boolean apply(    ServiceDescriptor serviceDescriptor){
      return serviceDescriptor.getType().equals(type);
    }
  }
);
}
 

Example 4

From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/record/.

Source file: SmartPoster.java

  19 
vote

public static SmartPoster parse(NdefRecord[] recordsRaw){
  try {
    Iterable<ParsedNdefRecord> records=NdefMessageParser.getRecords(recordsRaw);
    UriRecord uri=Iterables.getOnlyElement(Iterables.filter(records,UriRecord.class));
    TextRecord title=getFirstIfExists(records,TextRecord.class);
    ImageRecord image=getFirstIfExists(records,ImageRecord.class);
    RecommendedAction action=parseRecommendedAction(recordsRaw);
    String type=parseType(recordsRaw);
    return new SmartPoster(uri,title,image,action,type);
  }
 catch (  NoSuchElementException e) {
    throw new IllegalArgumentException(e);
  }
}
 

Example 5

From project appdriver, under directory /android/src/com/google/android/testing/nativedriver/server/handler/.

Source file: AndroidNativeFindChildElements.java

  19 
vote

@Override public ResultType call() throws Exception {
  response=newResponse();
  List<WebElement> elements=getElement().findElements(by);
  Function<WebElement,Map<String,String>> transform=new Function<WebElement,Map<String,String>>(){
    public Map<String,String> apply(    WebElement element){
      return ImmutableMap.of("ELEMENT",getKnownElements().add(element));
    }
  }
;
  Set<Map<String,String>> elementIds=Sets.newLinkedHashSet(Iterables.transform(elements,transform));
  response.setValue(elementIds);
  return ResultType.SUCCESS;
}
 

Example 6

From project Arecibo, under directory /collector/src/main/java/com/ning/arecibo/collector/process/.

Source file: CollectorEventProcessor.java

  19 
vote

public void processEvent(final Event evt){
  final List<Event> events=new ArrayList<Event>();
  if (evt instanceof BatchedEvent) {
    events.addAll(((BatchedEvent)evt).getEvents());
  }
 else {
    events.add(evt);
  }
  eventsReceived.getAndAdd(events.size());
  final Collection<Event> filteredEvents=Lists.newArrayList(Iterables.filter(Iterables.transform(events,filter),Predicates.<Event>notNull()));
  eventsFiltered.addAndGet(events.size() - filteredEvents.size());
  for (  final Event event : filteredEvents) {
    for (    final EventHandler handler : eventHandlers) {
      try {
        handler.handle(event);
      }
 catch (      RuntimeException ruEx) {
        log.warn("Exception handling event",ruEx);
      }
    }
  }
}
 

Example 7

From project artifactory-plugin, under directory /src/main/java/org/jfrog/hudson/.

Source file: ArtifactoryRedeployPublisher.java

  19 
vote

private boolean isBuildFromM2ReleasePlugin(AbstractBuild<?,?> build){
  List<Cause> causes=build.getCauses();
  return !causes.isEmpty() && Iterables.any(causes,new Predicate<Cause>(){
    public boolean apply(    Cause input){
      return "org.jvnet.hudson.plugins.m2release.ReleaseCause".equals(input.getClass().getName());
    }
  }
);
}
 

Example 8

From project astyanax, under directory /src/main/java/com/netflix/astyanax/serializers/.

Source file: AbstractSerializer.java

  19 
vote

public List<ByteBuffer> toBytesList(Iterable<T> list){
  List<ByteBuffer> bytesList=new ArrayList<ByteBuffer>(Iterables.size(list));
  for (  T s : list) {
    bytesList.add(toByteBuffer(s));
  }
  return bytesList;
}
 

Example 9

From project atlas, under directory /src/main/java/com/ning/atlas/components/aws/.

Source file: EC2SecurityGroupProvisioner.java

  19 
vote

@Override public String perform(Host host,Uri<? extends Component> uri,Deployment d) throws Exception {
  AtlasConfiguration config=AtlasConfiguration.global();
  Credentials creds=new AWS.Credentials();
  creds.setAccessKey(config.lookup("aws.key").get());
  creds.setSecretKey(config.lookup("aws.secret").get());
  AWSEC2Client ec2Api=AWS.ec2Api(creds);
  IAMApi iam=AWS.iamApi(creds);
  final String group_name=uri.getFragment();
  Set<SecurityGroup> groups=ec2Api.getSecurityGroupServices().describeSecurityGroupsInRegion(null,group_name);
  SecurityGroup security_group;
  if (groups.size() > 0) {
    security_group=Iterables.get(groups,0);
  }
 else {
    security_group=createNewGroup(ec2Api,group_name);
  }
  updateGroup(uri,ec2Api,iam,security_group);
  return "okay";
}
 

Example 10

From project atlassian-rest-cli, under directory /rest-cli-runner/src/main/java/com/galeoconsulting/leonardinius/api/impl/.

Source file: ServletVelocityHelperImpl.java

  19 
vote

@Override public SessionBean getSessionBean(final String sessionId){
  if (StringUtils.isBlank(sessionId)) {
    return null;
  }
  Iterable<SessionBean> iterable=Iterables.filter(getAllSessionBeans(),new Predicate<SessionBean>(){
    @Override public boolean apply(    @Nullable SessionBean input){
      return StringUtils.equals(sessionId,input.getSessionId());
    }
  }
);
  return iterable.iterator().hasNext() ? iterable.iterator().next() : null;
}
 

Example 11

From project atunit, under directory /atunit/src/main/java/atunit/core/.

Source file: PluginUtils.java

  19 
vote

/** 
 * Gets the single ContainerPlugin specified in the Plugins annotation's list.
 * @return the ContainerPlugin's class, or null if none is specified.
 * @throws IncompatiblePluginsException if multiple ContainerPlugins are specified in the annotation.
 */
@SuppressWarnings("unchecked") public static Class<? extends ContainerPlugin> getContainerPluginClass(Class<?> testClass) throws IncompatiblePluginsException {
  Set<Class<? extends ContainerPlugin>> containers=Sets.newHashSet();
  for (  Class<?> plugin : getPluginClasses(testClass)) {
    if (ContainerPlugin.class.isAssignableFrom(plugin)) {
      Class<? extends ContainerPlugin> container=(Class<? extends ContainerPlugin>)plugin;
      containers.add(container);
    }
  }
  Class<? extends ContainerPlugin>[] containersArray=new Class[0];
switch (containers.size()) {
case 0:
    return null;
case 1:
  return Iterables.getOnlyElement(containers);
default :
throw new IncompatiblePluginsException(containers.toArray(containersArray));
}
}
 

Example 12

From project atunit_1, under directory /src/atunit/guice/.

Source file: GuiceContainer.java

  19 
vote

@Override @SuppressWarnings("unchecked") protected void configure(){
  Multimap<Type,Field> fieldsByType=Multimaps.newHashMultimap();
  for (  Field field : fields.keySet()) {
    fieldsByType.put(field.getGenericType(),field);
  }
  for (  Type type : fieldsByType.keySet()) {
    Collection<Field> fields=fieldsByType.get(type);
    if (fields.size() == 1) {
      Field field=Iterables.getOnlyElement(fields);
      TypeLiteral literal=TypeLiteral.get(type);
      bind(literal).toInstance(this.fields.get(field));
    }
  }
}
 

Example 13

From project azkaban, under directory /azkaban/src/java/azkaban/flow/.

Source file: GroupedFlow.java

  19 
vote

@Override public String getName(){
  return StringUtils.join(Iterables.transform(Arrays.asList(flows),new Function<Flow,String>(){
    @Override public String apply(    Flow flow){
      return flow.getName();
    }
  }
).iterator()," + ");
}
 

Example 14

From project b1-pack, under directory /cli/src/main/java/org/b1/pack/cli/.

Source file: FsFolderContent.java

  19 
vote

private void addFile(List<String> path,File file) throws IOException {
  if (path.isEmpty()) {
    addChildren(builderMap.get(Collections.<String>emptyList()),file);
  }
 else {
    PackEntry entry=new FsPackEntry(Iterables.getLast(path),file.lastModified());
    if (file.isFile()) {
      getParentBuilder(path).addFile(entry,file.length()).setContent(new FsFileContent(file));
    }
 else {
      addChildren(getParentBuilder(path).addFolder(entry),file);
    }
  }
}
 

Example 15

From project bamboo-sonar-integration, under directory /bamboo-sonar-common/src/main/java/com/marvelution/bamboo/plugins/sonar/common/predicates/.

Source file: SonarPredicates.java

  19 
vote

/** 
 * Get the Has Sonar Tasks  {@link Predicate}
 * @return the {@link Predicate}
 */
public static Predicate<Buildable> hasSonarTasks(){
  return new Predicate<Buildable>(){
    @Override public boolean apply(    Buildable buildable){
      return Iterables.any(buildable.getBuildDefinition().getTaskDefinitions(),isSonarTask());
    }
  }
;
}
 

Example 16

From project Betfair-Trickle, under directory /src/main/java/uk/co/onehp/trickle/controller/domain/.

Source file: DomainControllerImpl.java

  19 
vote

private List<Bet> betsFromTodayOrLater(List<Bet> bets){
  List<Bet> filteredBets;
  filteredBets=Lists.newArrayList(Iterables.filter(bets,new Predicate<Bet>(){
    @Override public boolean apply(    Bet bet){
      return bet.getHorse().getRace().getStartTime().isAfter(new LocalDateTime().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0));
    }
  }
));
  return filteredBets;
}
 

Example 17

From project bioportal-service, under directory /src/main/java/edu/mayo/cts2/framework/plugin/service/bioportal/transform/.

Source file: AbstractBioportalOntologyTransformTemplate.java

  19 
vote

/** 
 * Transform resource.
 * @param node the node
 * @return the r
 */
public R transformResource(Node node){
  String abbreviation=TransformUtils.getNamedChildText(node,ABBREVIATION);
  String ontologyId=TransformUtils.getNamedChildText(node,ONTOLOGY_ID);
  String displayLabel=TransformUtils.getNamedChildText(node,DISPLAY_LABEL);
  String description=TransformUtils.getNamedChildText(node,DESCRIPTION);
  String name=this.getName(ontologyId);
  String about=this.getAbout(name);
  R resource=this.createNewResource();
  resource.setAbout(about);
  resource=this.setName(resource,name);
  resource.setFormalName(displayLabel);
  resource.setResourceSynopsis(new EntryDescription());
  resource.getResourceSynopsis().setValue(ModelUtils.toTsAnyType(description));
  resource.addKeyword(abbreviation);
  resource.addKeyword(ontologyId);
  resource.addSourceAndRole(this.getSourceAndRoleReference(node));
  resource.setProperty(Iterables.toArray(this.getProperties(node,name),Property.class));
  resource.addProperty(this.createOntologyIdProperty(ontologyId));
  resource=this.decorateResource(node,resource);
  return resource;
}
 

Example 18

From project build-info, under directory /build-info-api/src/main/java/org/jfrog/build/api/builder/.

Source file: BuildInfoMavenBuilder.java

  19 
vote

private Module findModule(final String moduleKey){
  return Iterables.find(modules,new Predicate<Module>(){
    public boolean apply(    Module input){
      return input.getId().equals(moduleKey);
    }
  }
,null);
}
 

Example 19

From project bulk-builder-plugin, under directory /src/main/java/org/jenkinsci/plugins/bulkbuilder/model/.

Source file: Builder.java

  19 
vote

/** 
 * Build Jenkins projects
 */
protected int build(ArrayList filters){
  int i=0;
  Predicate<AbstractProject<?,?>> compositePredicate=Predicates.and(filters);
  List<AbstractProject<?,?>> projects=getProjects(this.view);
  Iterable<AbstractProject<?,?>> targetProjects=Iterables.filter(projects,compositePredicate);
  for (  AbstractProject<?,?> project : targetProjects) {
    LOGGER.log(Level.FINE,"Scheduling build for job '" + project.getDisplayName() + "'");
    if (performBuildProject(project)) {
      i++;
    }
  }
  return i;
}
 

Example 20

From project c10n, under directory /core/src/ext/guice/java/c10n/guice/.

Source file: C10NModule.java

  19 
vote

private Set<URL> getPackageURLs(){
  Iterable<URL> packages=Iterables.concat(Iterables.transform(Arrays.asList(packagePrefixes),new Function<String,Set<URL>>(){
    @Override public Set<URL> apply(    String prefix){
      return ClasspathHelper.forPackage(prefix);
    }
  }
));
  return Sets.newHashSet(packages);
}
 

Example 21

From project cdk, under directory /generator/src/main/java/org/richfaces/cdk/apt/.

Source file: AptSourceUtils.java

  19 
vote

private Entry<? extends ExecutableElement,? extends AnnotationValue> findAnnotationProperty(AnnotationMirror annotation,final String propertyName){
  try {
    return Iterables.find(getAnnotationValuesMap(annotation).entrySet(),new AnnotationAttributePredicate(propertyName));
  }
 catch (  NoSuchElementException e) {
    throw new CdkException("Attribute " + propertyName + " not found for annotation "+ annotation.getAnnotationType().toString());
  }
}
 

Example 22

From project Cinch, under directory /src/com/palantir/ptoss/cinch/core/.

Source file: BindingContext.java

  19 
vote

/** 
 * Returns the list of  {@link ModelUpdate} types in this binding context.
 * @param modelClass
 * @return the of {@link Class}es that implement  {@link ModelUpdate} in this binding context.
 */
public static List<Class<?>> findModelUpdateClass(final BindableModel modelClass){
  List<Class<?>> classes=Reflections.getTypesOfTypeForClassHierarchy(modelClass.getClass(),ModelUpdate.class);
  Predicate<Class<?>> isEnum=new Predicate<Class<?>>(){
    public boolean apply(    final Class<?> input){
      return input.isEnum();
    }
  }
;
  classes=Lists.newArrayList(Iterables.filter(classes,isEnum));
  for (  Class<?> iface : modelClass.getClass().getInterfaces()) {
    classes.addAll(Lists.newArrayList(Iterables.filter(Reflections.getTypesOfTypeForClassHierarchy(iface,ModelUpdate.class),isEnum)));
  }
  if (classes.size() == 0) {
    return null;
  }
  return classes;
}
 

Example 23

From project Citizens, under directory /src/core/net/citizensnpcs/resources/sk89q/.

Source file: CommandContext.java

  19 
vote

public CommandContext(String[] args){
  int i=1;
  for (; i < args.length; i++) {
    if (args[i].length() == 0) {
    }
 else     if (args[i].charAt(0) == '-' && args[i].matches("^-[a-zA-Z]+$")) {
      for (int k=1; k < args[i].length(); k++) {
        flags.add(args[i].charAt(k));
      }
      args[i]="";
    }
  }
  this.args=Iterables.toArray(Splitter.on(" ").omitEmptyStrings().split(Joiner.on(" ").skipNulls().join(args)),String.class);
}
 

Example 24

From project cloud-management, under directory /src/main/java/com/proofpoint/cloudmanagement/service/.

Source file: InstancesResource.java

  19 
vote

@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createInstance(final InstanceCreationRequest request,@Context UriInfo uriInfo){
  checkNotNull(request);
  checkNotNull(uriInfo);
  if (!instanceConnectorMap.containsKey(request.getProvider())) {
    return Response.status(Status.BAD_REQUEST).entity(new InstanceCreationFailedResponse(request,PROVIDER_UNAVAILABLE)).build();
  }
  if (instanceConnectorMap.get(request.getProvider()).getLocation(request.getLocation()) == null) {
    return Response.status(Status.BAD_REQUEST).entity(new InstanceCreationFailedResponse(request,LOCATION_UNAVAILABLE)).build();
  }
  if (!Iterables.any(instanceConnectorMap.get(request.getProvider()).getLocation(request.getLocation()).getAvailableSizes(),new Predicate<Size>(){
    @Override public boolean apply(    @Nullable Size size){
      return size.getSize().equals(request.getSize());
    }
  }
)) {
    return Response.status(Status.BAD_REQUEST).entity(new InstanceCreationFailedResponse(request,SIZE_UNAVAILABLE)).build();
  }
  String instanceId=instanceConnectorMap.get(request.getProvider()).createInstance(request.getSize(),request.getNamePrefix(),request.getLocation());
  for (  InstanceCreationNotifier instanceCreationNotifier : instanceCreationNotifiers) {
    instanceCreationNotifier.notifyInstanceCreated(instanceId);
  }
  return Response.created(InstanceResource.constructSelfUri(uriInfo,instanceId)).build();
}
 

Example 25

From project clustermeister, under directory /provisioning/src/main/java/com/github/nethad/clustermeister/provisioning/ec2/.

Source file: AmazonInstanceManager.java

  19 
vote

/** 
 * Create a new instance. TODO: enable to launch more than one instace
 * @param userMetaData A map containing optional user-defined tags.
 * @return	Meta data object for the created instance.
 * @throws RunNodesException	If the instance could not be started.
 */
NodeMetadata createInstance(AmazonNodeConfiguration nodeConfiguration,Optional<Map<String,String>> userMetaData) throws RunNodesException {
  logger.info("Creating a new instance...");
  ComputeService computeService=contextManager.getEagerContext().getComputeService();
  Template template=nodeConfiguration.getTemplate(computeService.templateBuilder());
  Optional<String> group=nodeConfiguration.getProfile().getGroup();
  String groupName=group.or(DEFAULT_GROUP_NAME);
  setTemplateOptions(template,nodeConfiguration,userMetaData);
  Set<? extends NodeMetadata> instances=computeService.createNodesInGroup(groupName,1,template);
  NodeMetadata metadata=Iterables.getOnlyElement(instances);
  if (!nodeConfiguration.getCredentials().isPresent()) {
    AmazonGeneratedKeyPairCredentials credentials=new AmazonGeneratedKeyPairCredentials(String.format("node#%s",metadata.getId()),metadata.getCredentials().getUser(),metadata.getCredentials().getPrivateKey());
    nodeConfiguration.setCredentials(credentials);
  }
  logger.info("Instance {} created.",metadata.getId());
  return metadata;
}
 

Example 26

From project commons-j, under directory /src/main/java/nerds/antelax/commons/net/pubsub/.

Source file: PubSubServerContextListener.java

  19 
vote

@Override public synchronized void contextInitialized(final ServletContextEvent ctx){
  final ServletContext sc=ctx.getServletContext();
  final Collection<InetSocketAddress> cluster=sc != null ? NetUtil.hostPortPairsFromString(sc.getInitParameter(CLUSTER_INIT_PARAM),PubSubServer.DEFAULT_ADDRESS.getPort()) : EMPTY;
  REMOTE_SERVERS.set(Collections2.filter(cluster,Predicates.not(NetUtil.machineLocalSocketAddress())));
  if (Iterables.any(cluster,NetUtil.machineLocalSocketAddress())) {
    server=new PubSubServer(cluster);
    ctx.getServletContext().log("Starting PubSub server, this machine is part of the cluster definition[" + cluster + "]");
    server.start();
  }
 else {
    server=null;
    ctx.getServletContext().log("No PubSub server started, remotes available for final clients are " + remoteServers());
  }
}
 

Example 27

From project community-plugins, under directory /deployit-cli-plugins/mustachifier/src/main/java/ext/deployit/community/cli/mustachify/.

Source file: Mustachifier.java

  19 
vote

@Override public DarEntryTransformer apply(final DarManifestEntry input){
  return Iterables.find(transformers,new Predicate<DarEntryTransformer>(){
    @Override public boolean apply(    DarEntryTransformer transformer){
      boolean matches=transformer.matches(input);
      if (matches && LOGGER.isDebugEnabled()) {
        LOGGER.debug("Matched '{}' to DAR entry '{}'",transformer,input);
      }
      return matches;
    }
  }
,DarEntryTransformer.NULL);
}
 

Example 28

From project core_4, under directory /impl/src/main/java/org/richfaces/application/.

Source file: ServiceLoader.java

  19 
vote

public static <S>S loadService(Class<S> serviceClass,Class<? extends S> defaultImplementation){
  Collection<Class<? extends S>> serviceClasses=loadServiceClasses(serviceClass);
  try {
    return createInstance(Iterables.getLast(serviceClasses));
  }
 catch (  NoSuchElementException e) {
    return createInstance(defaultImplementation);
  }
}
 

Example 29

From project cp-common-utils, under directory /src/com/clarkparsia/common/collect/.

Source file: Iterables2.java

  19 
vote

/** 
 * Same as  {@link Iterables#find} except it does not throw {@link NoSuchElementException} if the result is not found.
 * @param theIterable	the iterable to search
 * @param thePredicate	the predicate to use
 * @return true if an element in the Iterable satisfies the predicate, false otherwise
 */
public static <T>boolean find(final Iterable<T> theIterable,final Predicate<? super T> thePredicate){
  try {
    return Iterables.find(theIterable,thePredicate) != null;
  }
 catch (  NoSuchElementException e) {
    return false;
  }
}
 

Example 30

From project cp-openrdf-utils, under directory /core/src/com/clarkparsia/openrdf/.

Source file: ExtRepository.java

  19 
vote

/** 
 * Return the superclasses of the given resource
 * @param theRes the resource
 * @return the resource's superclasses
 */
public Iterable<Resource> getSuperclasses(final Resource theRes){
  return Iterables.transform(new IterationIterable<Statement>(new Supplier<RepositoryResult<Statement>>(){
    public RepositoryResult<Statement> get(){
      return getStatements(theRes,RDFS.SUBCLASSOF,null);
    }
  }
),new Function<Statement,Resource>(){
    public Resource apply(    Statement theStmt){
      return (Resource)theStmt.getObject();
    }
  }
);
}
 

Example 31

From project crunch, under directory /crunch/src/main/java/org/apache/crunch/lib/.

Source file: Sort.java

  19 
vote

public static void configureOrdering(Configuration conf,Order... orders){
  conf.set(CRUNCH_ORDERING_PROPERTY,Joiner.on(",").join(Iterables.transform(Arrays.asList(orders),new Function<Order,String>(){
    @Override public String apply(    Order o){
      return o.name();
    }
  }
)));
}
 

Example 32

From project culvert, under directory /culvert-accumulo/src/main/java/com/bah/culvert/accumulo/database/.

Source file: AccumuloTableAdapter.java

  19 
vote

@Override public void put(Put put){
  try {
    writer.addMutations(Iterables.transform(put.getKeyValueList(),CKeyValuetoMutation));
    writer.flush();
  }
 catch (  Exception e) {
    throw Exceptions.asRuntime(e);
  }
}
 

Example 33

From project curator, under directory /curator-examples/src/main/java/discovery/.

Source file: DiscoveryExample.java

  19 
vote

private static void deleteInstance(String[] args,String command,List<ExampleServer> servers){
  if (args.length != 1) {
    System.err.println("syntax error (expected delete <name>): " + command);
    return;
  }
  final String serviceName=args[0];
  ExampleServer server=Iterables.find(servers,new Predicate<ExampleServer>(){
    @Override public boolean apply(    ExampleServer server){
      return server.getThisInstance().getName().endsWith(serviceName);
    }
  }
,null);
  if (server == null) {
    System.err.println("No servers found named: " + serviceName);
    return;
  }
  servers.remove(server);
  Closeables.closeQuietly(server);
  System.out.println("Removed a random instance of: " + serviceName);
}
 

Example 34

From project daleq, under directory /daleq-core/src/main/java/de/brands4friends/daleq/core/internal/builder/.

Source file: ImmutableTableData.java

  19 
vote

@Override public Iterable<Optional<String>> getValuesOfField(final String fieldName){
  return Iterables.transform(rows,new Function<RowData,Optional<String>>(){
    @Override public Optional<String> apply(    @Nullable final RowData row){
      if (row == null) {
        return null;
      }
      return row.getFieldBy(fieldName).getValue();
    }
  }
);
}
 

Example 35

From project eclipse-task-editor, under directory /plugins/de.sebastianbenz.task/xtend-gen/de/sebastianbenz/task/generator/.

Source file: HtmlGenerator.java

  19 
vote

public boolean isFirst(final Task task){
  Container _parent=task.getParent();
  EList<Content> _children=_parent.getChildren();
  Iterable<Task> tasks=Iterables.<Task>filter(_children,Task.class);
  Iterator<Task> _iterator=tasks.iterator();
  Task _next=_iterator.next();
  return Objects.equal(_next,task);
}
 

Example 36

From project edna-rcp, under directory /org.edna.datamodel.transformations/src/org/edna/datamodel/transformations/m2m/.

Source file: Dsl2UmlTransformation.java

  19 
vote

/** 
 * Types which only contain elements, whose type is a primitive type, are considered as Datatype Wrapper. References to those types should be just a Property without association in the target UML model.
 */
private boolean isDataTypeWrapper(ComplexType type){
  return Iterables.all(type.getElements(),new Predicate<ElementDeclaration>(){
    public boolean apply(    ElementDeclaration input){
      return input.getRef() == null;
    }
  }
);
}
 

Example 37

From project elephant-twin, under directory /com.twitter.elephanttwin/src/main/java/com/twitter/elephanttwin/util/.

Source file: HdfsUtils.java

  19 
vote

/** 
 * Returns a InputSupplier that returns a stream which is the concatenation of all source streams. Note that this method may not make sense for certain binary-encoded streams, but is convenient for processing multiple Hadoop part files in a line-delimited record format.
 * @param streams source streams
 * @return InputSupplier supplying a concatenated stream
 * @throws IOException
 */
public static InputSupplier<InputStream> getInputStreamSupplier(InputStream... streams) throws IOException {
  return ByteStreams.join(Iterables.transform(Lists.newArrayList(streams),new Function<InputStream,InputSupplier<InputStream>>(){
    @Override public InputSupplier<InputStream> apply(    final InputStream stream){
      return new InputSupplier<InputStream>(){
        @Override public InputStream getInput() throws IOException {
          return stream;
        }
      }
;
    }
  }
));
}
 

Example 38

From project EMF-IncQuery, under directory /plugins/org.eclipse.viatra2.emf.incquery.tooling.core/src/org/eclipse/viatra2/emf/incquery/core/project/.

Source file: ProjectGenerationHelper.java

  19 
vote

/** 
 * @param extensionMap
 * @param extension
 * @param id
 * @return
 */
private static boolean isExtensionInMap(Multimap<String,IPluginExtension> extensionMap,final IPluginExtension extension,String id){
  boolean extensionToCreateFound=false;
  if (extensionMap.containsKey(id)) {
    extensionToCreateFound=Iterables.any(extensionMap.get(id),new Predicate<IPluginExtension>(){
      @Override public boolean apply(      IPluginExtension ex){
        return ex.getPoint().equals(extension.getPoint());
      }
    }
);
  }
  return extensionToCreateFound;
}
 

Example 39

From project event-collector, under directory /event-combiner/src/main/java/com/proofpoint/event/combiner/.

Source file: StoredObjectCombiner.java

  19 
vote

private static List<StoredObject> getNewObjects(List<StoredObject> stagedObjects,Set<StoredObject> alreadyCombinedObjects){
  Set<URI> combined=newHashSet(Iterables.transform(alreadyCombinedObjects,StoredObject.GET_LOCATION_FUNCTION));
  List<StoredObject> newObjects=Lists.newArrayList();
  for (  StoredObject stagedObject : stagedObjects) {
    if (!combined.contains(stagedObject.getLocation())) {
      newObjects.add(stagedObject);
    }
  }
  return newObjects;
}
 

Example 40

From project ExperienceMod, under directory /ExperienceMod/src/com/comphenix/xp/extra/.

Source file: ServiceProvider.java

  19 
vote

/** 
 * Retrieves a collection of every enabled service.
 * @return Every enabled service.
 */
public Iterable<TService> getEnabledServices(){
  return Iterables.filter(nameLookup.values(),new Predicate<TService>(){
    @Override public boolean apply(    TService service){
      return isEnabled(service);
    }
  }
);
}