Android Open Source - BackbeamAndroid Collection Constraint






From Project

Back to project page BackbeamAndroid.

License

The source code is released under:

Copyright (c) 2012 Level Apps S.L. <http://backbeam.io> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software...

If you think the Android project BackbeamAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package io.backbeam;
//from   ww w.j a v  a 2  s. c  o m
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CollectionConstraint {
  
  private List<String> ids = new ArrayList<String>();
  
  public CollectionConstraint addObject(BackbeamObject object) {
    if (object.getId() != null) {
      ids.add(object.getId());
    }
    return this;
  }
  
  public CollectionConstraint addObjects(List<BackbeamObject> objects) {
    for (BackbeamObject obj : objects) {
      addObject(obj);
    }
    return this;
  }
  
  public CollectionConstraint addIdentifier(String identifier) {
    if (identifier != null) {
      ids.add(identifier);
    }
    return this;
  }
  
  public CollectionConstraint addIdentifiers(List<String> identifiers) {
    for (String identifier : identifiers) {
      if (identifier != null) {
        ids.add(identifier);
      }
    }
    return this;
  }
  
  private void addIdentifier(String identifier, String prefix) {
    ids.add(prefix+identifier);
  }
  
  private void addIdentifiers(List<String> identifiers, String prefix) {
    for (String identifier : identifiers) {
      ids.add(prefix+identifier);
    }
  }
  
  public void addTwitterIdentifier(String identifier) {
    addIdentifier(identifier, "tw:");
  }
  
  public void addTwitterIdentifiers(List<String> identifiers) {
    addIdentifiers(identifiers, "tw:");
  }
  
  public void addFacebookIdentifier(String identifier) {
    addIdentifier(identifier, "fb:");
  }
  
  public void addFacebookIdentifiers(List<String> identifiers) {
    addIdentifiers(identifiers, "fb:");
  }
  
  public void addEmailAddress(String identifier) {
    addIdentifier(identifier, "email:");
  }
  
  public void addEmailAddresses(List<String> identifiers) {
    addIdentifiers(identifiers, "email:");
  }
  
  public void addGooglePlus(String identifier) {
    addIdentifier(identifier, "gp:");
  }
  
  public void addGooglePlus(List<String> identifiers) {
    addIdentifiers(identifiers, "gp:");
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
      Iterator<String> iter = ids.iterator();
      if (iter.hasNext())
          sb.append(iter.next());
      while (iter.hasNext()) {
          sb.append("\n");
          sb.append(iter.next());
      }
      return sb.toString();
  }

}




Java Source Code List

io.backbeam.BackbeamException.java
io.backbeam.BackbeamObject.java
io.backbeam.Backbeam.java
io.backbeam.Callback.java
io.backbeam.CollectionConstraint.java
io.backbeam.ControllerRequestCallback.java
io.backbeam.FetchCallback.java
io.backbeam.FetchPolicy.java
io.backbeam.FileUpload.java
io.backbeam.GCMBroadcastReceiver.java
io.backbeam.GCMCallback.java
io.backbeam.GCMIntentService.java
io.backbeam.IntentCallback.java
io.backbeam.JoinResult.java
io.backbeam.Json.java
io.backbeam.ListCallback.java
io.backbeam.Location.java
io.backbeam.NearFetchCallback.java
io.backbeam.ObjectCallback.java
io.backbeam.OperationCallback.java
io.backbeam.PushNotification.java
io.backbeam.Query.java
io.backbeam.RealTimeConnectionListener.java
io.backbeam.RealTimeEventListener.java
io.backbeam.RemoveCallback.java
io.backbeam.RequestCallback.java
io.backbeam.RequestDataCallback.java
io.backbeam.SignupCallback.java
io.backbeam.Utils.java