1717 */
1818package org .apache .beam .sdk .options ;
1919
20+ import static org .apache .beam .sdk .util .Preconditions .checkArgumentNotNull ;
2021import static org .apache .beam .vendor .guava .v32_1_2_jre .com .google .common .base .Preconditions .checkArgument ;
21- import static org .apache .beam .vendor .guava .v32_1_2_jre .com .google .common .base .Preconditions .checkNotNull ;
2222
2323import com .fasterxml .jackson .annotation .JsonIgnore ;
2424import com .fasterxml .jackson .core .JsonGenerator ;
8282 * introspection of the proxy class to store and retrieve values based off of the property name.
8383 *
8484 * <p>Unset properties use the {@code @Default} metadata on the getter to return values. If there is
85- * no {@code @Default} annotation on the getter, then a <a
86- * href= "https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">default</a> as
87- * per the Java Language Specification for the expected return type is returned.
85+ * no {@code @Default} annotation on the getter, then a <a href=
86+ * "https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">default</a> as per the
87+ * Java Language Specification for the expected return type is returned.
8888 *
8989 * <p>In addition to the getter/setter pairs, this proxy invocation handler supports {@link
9090 * Object#equals(Object)}, {@link Object#hashCode()}, {@link Object#toString()} and {@link
@@ -122,7 +122,8 @@ private ComputedProperties(
122122 <T extends PipelineOptions > ComputedProperties updated (
123123 Class <T > iface , T instance , List <PropertyDescriptor > propertyDescriptors ) {
124124
125- // these all use mutable maps and then copyOf, rather than a builder because builders enforce
125+ // these all use mutable maps and then copyOf, rather than a builder because
126+ // builders enforce
126127 // all keys are unique, and its possible they are not here.
127128 Map <String , String > allNewGetters = Maps .newHashMap (gettersToPropertyNames );
128129 Map <String , String > allNewSetters = Maps .newHashMap (settersToPropertyNames );
@@ -147,7 +148,8 @@ <T extends PipelineOptions> ComputedProperties updated(
147148 @ SuppressFBWarnings ("SE_BAD_FIELD" )
148149 private volatile ComputedProperties computedProperties ;
149150
150- // ProxyInvocationHandler implements Serializable only for the sake of throwing an informative
151+ // ProxyInvocationHandler implements Serializable only for the sake of throwing
152+ // an informative
151153 // exception in writeObject()
152154 /**
153155 * Enumerating {@code options} must always be done on a copy made before accessing or deriving
@@ -217,7 +219,8 @@ public Object invoke(Object proxy, Method method, Object[] args) {
217219 ComputedProperties properties = computedProperties ;
218220 if (properties .gettersToPropertyNames .containsKey (methodName )) {
219221 String propertyName = properties .gettersToPropertyNames .get (methodName );
220- // we can't use computeIfAbsent here because evaluating the default may cause more properties
222+ // we can't use computeIfAbsent here because evaluating the default may cause
223+ // more properties
221224 // to be evaluated, and computeIfAbsent is not re-entrant.
222225 if (!options .containsKey (propertyName )) {
223226 // Lazy bind the default to the method.
@@ -286,7 +289,7 @@ static BoundValue fromDefault(@Nullable Object value) {
286289 * @return An object that implements the interface {@code <T>}.
287290 */
288291 <T extends PipelineOptions > T as (Class <T > iface ) {
289- checkNotNull (iface );
292+ checkArgumentNotNull (iface );
290293 checkArgument (iface .isInterface (), "Not an interface: %s" , iface );
291294
292295 T existingOption = computedProperties .interfaceToProxyCache .getInstance (iface );
@@ -376,8 +379,10 @@ class PipelineOptionsDisplayData implements HasDisplayData {
376379 */
377380 @ Override
378381 public void populateDisplayData (DisplayData .Builder builder ) {
379- // We must first make a copy of the current options because a concurrent modification
380- // may add a new option after we have derived optionSpecs but before we have enumerated
382+ // We must first make a copy of the current options because a concurrent
383+ // modification
384+ // may add a new option after we have derived optionSpecs but before we have
385+ // enumerated
381386 // all the pipeline options.
382387 Map <String , BoundValue > copiedOptions = new HashMap <>(options );
383388 Set <PipelineOptionSpec > optionSpecs =
@@ -396,8 +401,10 @@ public void populateDisplayData(DisplayData.Builder builder) {
396401
397402 for (PipelineOptionSpec optionSpec : specs ) {
398403 if (!optionSpec .shouldSerialize ()) {
399- // Options that are excluded for serialization (i.e. those with @JsonIgnore) are also
400- // excluded from display data. These options are generally not useful for display.
404+ // Options that are excluded for serialization (i.e. those with @JsonIgnore) are
405+ // also
406+ // excluded from display data. These options are generally not useful for
407+ // display.
401408 continue ;
402409 }
403410
@@ -481,7 +488,8 @@ private static String displayDataString(@Nullable Object value) {
481488 return Arrays .deepToString ((Object []) value );
482489 }
483490
484- // At this point, we have some type of primitive array. Arrays.deepToString(..) requires an
491+ // At this point, we have some type of primitive array. Arrays.deepToString(..)
492+ // requires an
485493 // Object array, but will unwrap nested primitive arrays.
486494 String wrapped = Arrays .deepToString (new Object [] {value });
487495 return wrapped .substring (1 , wrapped .length () - 1 );
@@ -514,12 +522,17 @@ private Multimap<String, PipelineOptionSpec> buildOptionNameToSpecMap(
514522 // Filter out overridden options
515523 for (Map .Entry <String , Collection <PipelineOptionSpec >> entry : optionsMap .asMap ().entrySet ()) {
516524
517- /* Compare all interfaces for an option pairwise (iface1, iface2) to look for type
518- hierarchies. If one is the base-class of the other, remove it from the output and continue
519- iterating.
520-
521- This is an N^2 operation per-option, but the number of interfaces defining an option
522- should always be small (usually 1). */
525+ /*
526+ * Compare all interfaces for an option pairwise (iface1, iface2) to look for
527+ * type
528+ * hierarchies. If one is the base-class of the other, remove it from the output
529+ * and continue
530+ * iterating.
531+ *
532+ * This is an N^2 operation per-option, but the number of interfaces defining an
533+ * option
534+ * should always be small (usually 1).
535+ */
523536 List <PipelineOptionSpec > specs = Lists .newArrayList (entry .getValue ());
524537 if (specs .size () < 2 ) {
525538 // Only one known implementing interface, no need to check for inheritance
@@ -600,9 +613,9 @@ private static Object getValueFromJson(JsonNode node, Method method) {
600613
601614 /**
602615 * Returns a default value for the method based upon {@code @Default} metadata on the getter to
603- * return values. If there is no {@code @Default} annotation on the getter, then a <a
604- * href= "https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">default</a> as
605- * per the Java Language Specification for the expected return type is returned.
616+ * return values. If there is no {@code @Default} annotation on the getter, then a <a href=
617+ * "https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">default</a> as per
618+ * the Java Language Specification for the expected return type is returned.
606619 *
607620 * @param proxy The proxy object for which we are attempting to get the default.
608621 * @param method The getter method that was invoked.
@@ -651,7 +664,8 @@ private Object getDefault(PipelineOptions proxy, Method method) {
651664 }
652665
653666 /*
654- * We need to make sure that we return something appropriate for the return type. Thus we return
667+ * We need to make sure that we return something appropriate for the return
668+ * type. Thus we return
655669 * a default value as defined by the JLS.
656670 */
657671 return Defaults .defaultValue (method .getReturnType ());
@@ -750,7 +764,8 @@ public void serialize(PipelineOptions value, JsonGenerator jgen, SerializerProvi
750764 throws IOException {
751765 ProxyInvocationHandler handler = (ProxyInvocationHandler ) Proxy .getInvocationHandler (value );
752766 PipelineOptionsFactory .Cache cache = PipelineOptionsFactory .CACHE .get ();
753- // We first copy and then filter out any properties that have been modified since
767+ // We first copy and then filter out any properties that have been modified
768+ // since
754769 // the last serialization of this PipelineOptions and then verify that
755770 // they are all serializable.
756771 Map <String , BoundValue > filteredOptions = Maps .newHashMap (handler .options );
0 commit comments