< prev index next >

src/java.base/share/classes/java/security/cert/PKIXParameters.java

Print this page

        

@@ -118,12 +118,12 @@
         throws InvalidAlgorithmParameterException
     {
         setTrustAnchors(trustAnchors);
 
         this.unmodInitialPolicies = Collections.<String>emptySet();
-        this.certPathCheckers = new ArrayList<PKIXCertPathChecker>();
-        this.certStores = new ArrayList<CertStore>();
+        this.certPathCheckers = new ArrayList<>();
+        this.certStores = new ArrayList<>();
     }
 
     /**
      * Creates an instance of {@code PKIXParameters} that
      * populates the set of most-trusted CAs from the trusted

@@ -142,11 +142,11 @@
         throws KeyStoreException, InvalidAlgorithmParameterException
     {
         if (keystore == null)
             throw new NullPointerException("the keystore parameter must be " +
                 "non-null");
-        Set<TrustAnchor> hashSet = new HashSet<TrustAnchor>();
+        Set<TrustAnchor> hashSet = new HashSet<>();
         Enumeration<String> aliases = keystore.aliases();
         while (aliases.hasMoreElements()) {
             String alias = aliases.nextElement();
             if (keystore.isCertificateEntry(alias)) {
                 Certificate cert = keystore.getCertificate(alias);

@@ -154,12 +154,12 @@
                     hashSet.add(new TrustAnchor((X509Certificate)cert, null));
             }
         }
         setTrustAnchors(hashSet);
         this.unmodInitialPolicies = Collections.<String>emptySet();
-        this.certPathCheckers = new ArrayList<PKIXCertPathChecker>();
-        this.certStores = new ArrayList<CertStore>();
+        this.certPathCheckers = new ArrayList<>();
+        this.certStores = new ArrayList<>();
     }
 
     /**
      * Returns an immutable {@code Set} of the most-trusted
      * CAs.

@@ -205,11 +205,11 @@
                 throw new ClassCastException("all elements of set must be "
                     + "of type java.security.cert.TrustAnchor");
             }
         }
         this.unmodTrustAnchors = Collections.unmodifiableSet
-                (new HashSet<TrustAnchor>(trustAnchors));
+                (new HashSet<>(trustAnchors));
     }
 
     /**
      * Returns an immutable {@code Set} of initial
      * policy identifiers (OID strings), indicating that any one of these

@@ -254,11 +254,11 @@
                 if (!(i.next() instanceof String))
                     throw new ClassCastException("all elements of set must be "
                         + "of type java.lang.String");
             }
             this.unmodInitialPolicies =
-                Collections.unmodifiableSet(new HashSet<String>(initialPolicies));
+                Collections.unmodifiableSet(new HashSet<>(initialPolicies));
         } else
             this.unmodInitialPolicies = Collections.<String>emptySet();
     }
 
     /**

@@ -278,19 +278,19 @@
      *
      * @see #getCertStores
      */
     public void setCertStores(List<CertStore> stores) {
         if (stores == null) {
-            this.certStores = new ArrayList<CertStore>();
+            this.certStores = new ArrayList<>();
         } else {
             for (Iterator<CertStore> i = stores.iterator(); i.hasNext();) {
                 if (!(i.next() instanceof CertStore)) {
                     throw new ClassCastException("all elements of list must be "
                         + "of type java.security.cert.CertStore");
                 }
             }
-            this.certStores = new ArrayList<CertStore>(stores);
+            this.certStores = new ArrayList<>(stores);
         }
     }
 
     /**
      * Adds a {@code CertStore} to the end of the list of

@@ -314,11 +314,11 @@
      *
      * @see #setCertStores
      */
     public List<CertStore> getCertStores() {
         return Collections.unmodifiableList
-                (new ArrayList<CertStore>(this.certStores));
+                (new ArrayList<>(this.certStores));
     }
 
     /**
      * Sets the RevocationEnabled flag. If this flag is true, the default
      * revocation checking mechanism of the underlying PKIX service provider

@@ -542,18 +542,17 @@
      * are not of type {@code java.security.cert.PKIXCertPathChecker}
      * @see #getCertPathCheckers
      */
     public void setCertPathCheckers(List<PKIXCertPathChecker> checkers) {
         if (checkers != null) {
-            List<PKIXCertPathChecker> tmpList =
-                        new ArrayList<PKIXCertPathChecker>();
+            List<PKIXCertPathChecker> tmpList = new ArrayList<>();
             for (PKIXCertPathChecker checker : checkers) {
                 tmpList.add((PKIXCertPathChecker)checker.clone());
             }
             this.certPathCheckers = tmpList;
         } else {
-            this.certPathCheckers = new ArrayList<PKIXCertPathChecker>();
+            this.certPathCheckers = new ArrayList<>();
         }
     }
 
     /**
      * Returns the {@code List} of certification path checkers.

@@ -565,11 +564,11 @@
      * {@code PKIXCertPathChecker}s (may be empty, but not
      * {@code null})
      * @see #setCertPathCheckers
      */
     public List<PKIXCertPathChecker> getCertPathCheckers() {
-        List<PKIXCertPathChecker> tmpList = new ArrayList<PKIXCertPathChecker>();
+        List<PKIXCertPathChecker> tmpList = new ArrayList<>();
         for (PKIXCertPathChecker ck : certPathCheckers) {
             tmpList.add((PKIXCertPathChecker)ck.clone());
         }
         return Collections.unmodifiableList(tmpList);
     }

@@ -665,15 +664,15 @@
         try {
             PKIXParameters copy = (PKIXParameters)super.clone();
 
             // must clone these because addCertStore, et al. modify them
             if (certStores != null) {
-                copy.certStores = new ArrayList<CertStore>(certStores);
+                copy.certStores = new ArrayList<>(certStores);
             }
             if (certPathCheckers != null) {
                 copy.certPathCheckers =
-                    new ArrayList<PKIXCertPathChecker>(certPathCheckers.size());
+                    new ArrayList<>(certPathCheckers.size());
                 for (PKIXCertPathChecker checker : certPathCheckers) {
                     copy.certPathCheckers.add(
                                     (PKIXCertPathChecker)checker.clone());
                 }
             }
< prev index next >