javax.annotation.Nullablecom.google.common.base.Optional



Project facebook/buck in file ...facebook.buck.java.FakeDefaultJavaLibraryRule.java (2013-05-22)
@@ -19,14 +19,13 @@ package com.facebook.buck.java;
 import com.facebook.buck.rules.BuildContext;
 import com.facebook.buck.rules.BuildRule;
 import com.facebook.buck.rules.CachingBuildRuleParams;
+import com.google.common.base.Optional;
 
 import java.io.IOException;
 import java.util.Map;
 import java.util.Set;
 import java.util.logging.Logger;
 
-import javax.annotation.Nullable;
-
 public class FakeDefaultJavaLibraryRule extends DefaultJavaLibraryRule {
   private final boolean hasUncachedDescendants;
   private final boolean ruleInputsAreCached;
@@ -34,7 +33,7 @@ public class FakeDefaultJavaLibraryRule extends DefaultJavaLibraryRule {
   protected FakeDefaultJavaLibraryRule(CachingBuildRuleParams cachingBuildRuleParams,
                                        Set<String> srcs,
                                        Set<String> resources,
-                                       @Nullable String proguardConfig,
+                                       Optional<String> proguardConfig,
                                        AnnotationProcessingParams annotationProcessingParams,
                                        boolean exportDeps,
                                        boolean hasUncachedDescendants,
@@ -44,7 +43,9 @@ public class FakeDefaultJavaLibraryRule extends DefaultJavaLibraryRule {
         resources,
         proguardConfig,
         annotationProcessingParams,
-        exportDeps);
+        exportDeps,
+        JavacOptionsUtil.DEFAULT_SOURCE_LEVEL,
+        JavacOptionsUtil.DEFAULT_TARGET_LEVEL);
 
     this.hasUncachedDescendants = hasUncachedDescendants;
     this.ruleInputsAreCached = ruleInputsAreCached;
Project ninjaframework/ninja in file ...re.src.main.java.ninja.utils.HttpCacheToolkit.java (2013-04-17)
@@ -16,11 +16,10 @@
 
 package ninja.utils;
 
-import javax.annotation.Nullable;
-
 import ninja.Context;
 import ninja.Result;
 
+import com.google.common.base.Optional;
 import com.google.inject.ImplementedBy;
 
 @ImplementedBy(HttpCacheToolkitImpl.class)
@@ -30,12 +29,12 @@ public interface HttpCacheToolkit {
      * Checks if resource has been modified.
      * Checks via etag or lastModified when etag not present.
      * 
-     * @param etag (can be null)
-     * @param lastModified (can be null)
+     * @param etag - may be absent
+     * @param lastModified - may be absent
      * @param context the Context of this request
      * @return true if modified / false if not.
      */
-    boolean isModified(@Nullable String etag, @Nullable Long lastModified, Context context);
+    boolean isModified(Optional<String> etag, Optional<Long> lastModified, Context context);
 
     /**
      * Adds etag to result.
Project SpongePowered/SpongeAPI in file ....main.java.org.spongepowered.api.GameRegistry.java (2014-10-01)
@@ -22,15 +22,15 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 package org.spongepowered.api;
 
+import com.google.common.base.Optional;
 import org.spongepowered.api.block.BlockType;
 import org.spongepowered.api.item.Item;
 
-import javax.annotation.Nullable;
-
 /**
- * Provides an easy way to retrieve objects from the {@link Game} based on their ids.
+ * Provides an easy way to retrieve types from a {@link Game}.
  */
 public interface GameRegistry {
 
@@ -40,8 +40,7 @@ public interface GameRegistry {
      * @param id The id to look up
      * @return The block or null if not found
      */
-    @Nullable
-    BlockType getBlock(String id);
+    Optional<BlockType> getBlock(String id);
 
     /**
      * Gets an {@link Item} by its identifier.
@@ -49,15 +48,13 @@ public interface GameRegistry {
      * @param id The id to look up
      * @return The item or null if not found
      */
-    @Nullable
-    Item getItem(String id);
+    Optional<Item> getItem(String id);
 
     /**
-     * Gets the id registered to the object.
+     * Gets the ID registered to the object.
      *
      * @param obj The object to look up
      * @return The id or null if none found
      */
-    @Nullable
-    String getID(Object obj);
+    Optional<String> getId(Object obj);
 }
Project facebook/buck in file ...dc/src.com.facebook.buck.java.PrebuiltJarRule.java (2013-05-22)
@@ -28,6 +28,7 @@ import com.facebook.buck.rules.BuildRuleType;
 import com.facebook.buck.rules.CachingBuildRuleParams;
 import com.facebook.buck.rules.RuleKey;
 import com.facebook.buck.step.Step;
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Supplier;
 import com.google.common.base.Suppliers;
@@ -41,8 +42,6 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
-import javax.annotation.Nullable;
-
 /**
  * A rule that establishes a pre-compiled JAR file as a dependency.
  */
@@ -50,8 +49,8 @@ public class PrebuiltJarRule extends AbstractCachingBuildRule
     implements JavaLibraryRule, HasClasspathEntries {
 
   private final String binaryJar;
-  @Nullable private final String sourceJar;
-  @Nullable private final String javadocUrl;
+  private final Optional<String> sourceJar;
+  private final Optional<String> javadocUrl;
   private final Supplier<ImmutableSetMultimap<BuildRule, String>>
       transitiveClasspathEntriesSupplier;
 
@@ -60,12 +59,12 @@ public class PrebuiltJarRule extends AbstractCachingBuildRule
 
   PrebuiltJarRule(CachingBuildRuleParams cachingBuildRuleParams,
       String classesJar,
-      String sourceJar,
-      String javadocUrl) {
+      Optional<String> sourceJar,
+      Optional<String> javadocUrl) {
     super(cachingBuildRuleParams);
     this.binaryJar = Preconditions.checkNotNull(classesJar);
-    this.sourceJar = sourceJar;
-    this.javadocUrl = javadocUrl;
+    this.sourceJar = Preconditions.checkNotNull(sourceJar);
+    this.javadocUrl = Preconditions.checkNotNull(javadocUrl);
 
     transitiveClasspathEntriesSupplier =
         Suppliers.memoize(new Supplier<ImmutableSetMultimap<BuildRule, String>>() {
@@ -100,11 +99,11 @@ public class PrebuiltJarRule extends AbstractCachingBuildRule
     return binaryJar;
   }
 
-  public String getSourceJar() {
+  public Optional<String> getSourceJar() {
     return sourceJar;
   }
 
-  public String getJavadocUrl() {
+  public Optional<String> getJavadocUrl() {
     return javadocUrl;
   }
 
@@ -169,8 +168,8 @@ public class PrebuiltJarRule extends AbstractCachingBuildRule
   public static class Builder extends AbstractCachingBuildRuleBuilder {
 
     private String binaryJar;
-    private String sourceJar;
-    private String javadocUrl;
+    private Optional<String> sourceJar = Optional.absent();
+    private Optional<String> javadocUrl = Optional.absent();
 
     private Builder() {}
 
@@ -211,13 +210,13 @@ public class PrebuiltJarRule extends AbstractCachingBuildRule
       return this;
     }
 
-    public Builder setSourceJar(String sourceJar) {
-      this.sourceJar = sourceJar;
+    public Builder setSourceJar(Optional<String> sourceJar) {
+      this.sourceJar = Preconditions.checkNotNull(sourceJar);
       return this;
     }
 
-    public Builder setJavadocUrl(String javadocUrl) {
-      this.javadocUrl = javadocUrl;
+    public Builder setJavadocUrl(Optional<String> javadocUrl) {
+      this.javadocUrl = Preconditions.checkNotNull(javadocUrl);
       return this;
     }
 
Project facebook/buck in file ...72/src.com.facebook.buck.java.JavaLibraryRule.java (2013-07-02)
@@ -19,12 +19,11 @@ package com.facebook.buck.java;
 import com.facebook.buck.model.AnnotationProcessingData;
 import com.facebook.buck.rules.BuildRule;
 import com.facebook.buck.rules.Sha1HashCode;
+import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSetMultimap;
 import com.google.common.collect.ImmutableSortedSet;
 
-import javax.annotation.Nullable;
-
 public interface JavaLibraryRule extends BuildRule, HasClasspathEntries {
   /**
    * @return The set of entries to pass to {@code javac}'s {@code -classpath} flag in order to
@@ -54,15 +53,14 @@ public interface JavaLibraryRule extends BuildRule, HasClasspathEntries {
   /**
    * Returns a SHA-1 hash that represents the ABI for the Java files returned by
    * {@link #getJavaSrcs()}. If {@link #getJavaSrcs()} returns an empty collection, then this will
-   * return a non-null value. The only requirement on the hash is that equal hashes imply equal
+   * return a non-absent value. The only requirement on the hash is that equal hashes imply equal
    * ABIs.
    * <p>
    * Because the ABI is computed as part of the build process, this rule cannot be invoked until
    * after this rule is built.
    * <p>
-   * Returns {@code null} if the rule did not build successfully, or if the ABI could not be
-   * extracted for any reason.
+   * Returns {@link Optional#absent()} if the rule did not build successfully, or if the ABI could
+   * not be extracted for any reason.
    */
-  @Nullable
-  public Sha1HashCode getAbiKey();
+  public Optional<Sha1HashCode> getAbiKey();
 }