Changeset 28607

Show
Ignore:
Timestamp:
01/09/08 16:49:32 (7 months ago)
Author:
sfermigier
Message:

Use annotation instead of explicit null checks.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.nuxeo.common/branches/1.4/src/main/java/org/nuxeo/common/collections/ArrayMap.java

    r19157 r28607  
    2121 
    2222import java.util.Map; 
     23 
     24import org.jetbrains.annotations.NotNull; 
    2325 
    2426/** 
     
    140142    } 
    141143 
    142     public V put(K key, V value) { 
    143         if (key == null) { 
    144             throw new NullPointerException(); 
    145         } 
    146  
     144    public V put(@NotNull K key, V value) { 
    147145        // handle the case where we don't have any attributes yet 
    148146        if (elements == null) { 
     
    177175    } 
    178176 
    179     public void add(K key, V value) { 
    180         if (key == null) { 
    181             throw new IllegalArgumentException(); 
    182         } 
    183  
     177    public void add(@NotNull K key, V value) { 
    184178        // handle the case where we don't have any attributes yet 
    185179        int insertIndex; 
  • org.nuxeo.common/branches/1.4/src/main/java/org/nuxeo/common/collections/DependencyTree.java

    r28168 r28607  
    156156    } 
    157157 
    158  
    159158    public List<Entry<K, T>> getPendingEntries() { 
    160159        List<Entry<K, T>> result = new ArrayList<Entry<K, T>>(); 
     
    205204        return list; 
    206205    } 
    207  
    208206 
    209207    public void clear() { 
  • org.nuxeo.common/branches/1.4/src/main/java/org/nuxeo/common/collections/ListenerList.java

    r20633 r28607  
    1919 
    2020package org.nuxeo.common.collections; 
     21 
     22import org.jetbrains.annotations.NotNull; 
    2123 
    2224 
     
    8587     * @param listener the listener to add 
    8688     */ 
    87     public synchronized void add(Object listener) { 
    88         if (listener == null) { 
    89             throw new IllegalArgumentException(); 
    90         } 
     89    public synchronized void add(@NotNull Object listener) { 
    9190        // check for duplicates 
    9291        final int oldSize = listeners.length; 
     
    147146     * @param listener the listener 
    148147     */ 
    149     public synchronized void remove(Object listener) { 
    150         if (listener == null) { 
    151             throw new IllegalArgumentException(); 
    152         } 
     148    public synchronized void remove(@NotNull Object listener) { 
    153149        int oldSize = listeners.length; 
    154150        for (int i = 0; i < oldSize; ++i) { 
  • org.nuxeo.common/branches/1.4/src/main/java/org/nuxeo/common/collections/PrimitiveArrays.java

    r28168 r28607  
    2525import java.util.Iterator; 
    2626import java.util.List; 
     27 
     28import org.jetbrains.annotations.NotNull; 
    2729 
    2830/** 
     
    196198    } 
    197199 
    198     public static List<?> toList(Object array) { 
    199         Class<?> arrType = array.getClass().getComponentType(); 
    200         if (arrType == null) { 
    201             throw new IllegalArgumentException("Not an array"); 
    202         } 
     200    public static List<?> toList(@NotNull Object array) { 
     201        @NotNull Class<?> arrType = array.getClass().getComponentType(); 
    203202        if (arrType.isPrimitive()) { 
    204203            if (arrType == Integer.TYPE) { 
  • org.nuxeo.common/branches/1.4/src/main/java/org/nuxeo/common/collections/SerializableArrayMap.java

    r22678 r28607  
    2222import java.io.Serializable; 
    2323import java.util.Map; 
     24 
     25import org.jetbrains.annotations.NotNull; 
    2426 
    2527/** 
     
    148150    } 
    149151 
    150     public V put(K key, V value) { 
    151         if (key == null) { 
    152             throw new NullPointerException(); 
    153         } 
     152    public V put(@NotNull K key, V value) { 
    154153 
    155154        // handle the case where we don't have any attributes yet 
     
    185184    } 
    186185 
    187     public void add(K key, V value) { 
    188         if (key == null) { 
    189             throw new IllegalArgumentException(); 
    190         } 
    191  
     186    public void add(@NotNull K key, V value) { 
    192187        // handle the case where we don't have any attributes yet 
    193188        int insertIndex; 
  • org.nuxeo.common/branches/1.4/src/main/java/org/nuxeo/common/utils/ArrayUtils.java

    r28478 r28607  
    2626import java.util.List; 
    2727import java.util.Set; 
     28 
     29import org.jetbrains.annotations.NotNull; 
    2830 
    2931/** 
     
    8486     */ 
    8587    @SuppressWarnings("unchecked") 
    86     public static <T> T[] intersect(final T[]... arrays) { 
    87         if (null == arrays) { 
    88             throw new IllegalArgumentException("arrays cannot be null"); 
    89         } 
    90  
     88    public static <T> T[] intersect(@NotNull final T[]... arrays) { 
    9189        final Class type = arrays.getClass().getComponentType() 
    9290                .getComponentType(); 
  • org.nuxeo.common/branches/1.4/src/main/java/org/nuxeo/common/xmap/XAnnotatedMember.java

    r26235 r28607  
    7171            throw new IllegalArgumentException( 
    7272                    String.format("%s, setter=%s, value=%s", e.getMessage(), 
    73                             setter, value)); 
     73                            setter, value), e); 
    7474        } 
    7575    }