You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/01/09 22:17:15 UTC

[jspwiki] 05/32: apply formats and fixes suggested by IntelliJ

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 1630b750f3dc0b721d98208e8c7a70cc5a23a3dc
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 21:16:31 2020 +0100

    apply formats and fixes suggested by IntelliJ
---
 .../main/java/org/apache/wiki/pages/PageLock.java  | 19 ++++-------
 .../java/org/apache/wiki/pages/PageManager.java    | 26 +++++++--------
 .../java/org/apache/wiki/pages/PageSorter.java     | 37 ++++++++++------------
 .../org/apache/wiki/pages/PageTimeComparator.java  |  6 ++--
 4 files changed, 39 insertions(+), 49 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageLock.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageLock.java
index ea93112..fcbc3a2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageLock.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageLock.java
@@ -18,11 +18,11 @@
  */
 package org.apache.wiki.pages;
 
+import org.apache.wiki.WikiPage;
+
 import java.io.Serializable;
 import java.util.Date;
 
-import org.apache.wiki.WikiPage;
-
 /**
  *  Describes a lock acquired by an user on a page.  For the most part,
  *  the regular developer does not have to instantiate this class.
@@ -49,11 +49,7 @@ public class PageLock
      *  @param acquired The timestamp when the lock is acquired
      *  @param expiry   The timestamp when the lock expires.
      */
-    public PageLock( WikiPage page, 
-                     String locker,
-                     Date acquired,
-                     Date expiry )
-    {
+    public PageLock( final WikiPage page, final String locker, final Date acquired, final Date expiry ) {
         m_page         = page.getName();
         m_locker       = locker;
         m_lockAcquired = (Date)acquired.clone();
@@ -106,15 +102,14 @@ public class PageLock
      *  
      *  @return Time left in minutes.
      */
-    public long getTimeLeft()
-    {
-        long time = m_lockExpiry.getTime() - new Date().getTime();
+    public long getTimeLeft() {
+        final long time = m_lockExpiry.getTime() - new Date().getTime();
 
-        return (time / (1000L * 60)) + 1;
+        return ( time / ( 1000L * 60 ) ) + 1;
     }
     
     public boolean isExpired() {
-        Date now = new Date();
+        final Date now = new Date();
         return now.after( getExpiryTime() );
     }
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index a78abca..dbdf1db 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -53,7 +53,7 @@ public interface PageManager extends WikiEventListener {
      * @return A Collection of WikiPage objects.
      * @throws ProviderException If the backend has problems.
      */
-    Collection<WikiPage> getAllPages() throws ProviderException;
+    Collection< WikiPage > getAllPages() throws ProviderException;
 
     /**
      * Fetches the page text from the repository.  This method also does some sanity checks,
@@ -65,7 +65,7 @@ public interface PageManager extends WikiEventListener {
      * @return The page content as a raw string
      * @throws ProviderException If the backend has issues.
      */
-    String getPageText(String pageName, int version) throws ProviderException;
+    String getPageText( String pageName, int version ) throws ProviderException;
 
     /**
      * Returns the WikiEngine to which this PageManager belongs to.
@@ -82,7 +82,7 @@ public interface PageManager extends WikiEventListener {
      * @param content Wikimarkup to save
      * @throws ProviderException If something goes wrong in the saving phase
      */
-    void putPageText(WikiPage page, String content) throws ProviderException;
+    void putPageText( WikiPage page, String content ) throws ProviderException;
 
     /**
      * Locks page for editing.  Note, however, that the PageManager will in no way prevent you from actually editing this page;
@@ -92,14 +92,14 @@ public interface PageManager extends WikiEventListener {
      * @param user Username to use for locking
      * @return null, if page could not be locked.
      */
-    PageLock lockPage(WikiPage page, String user);
+    PageLock lockPage( WikiPage page, String user );
 
     /**
      * Marks a page free to be written again.  If there has not been a lock, will fail quietly.
      *
      * @param lock A lock acquired in lockPage().  Safe to be null.
      */
-    void unlockPage(PageLock lock);
+    void unlockPage( PageLock lock );
 
     /**
      * Returns the current lock owner of a page.  If the page is not locked, will return null.
@@ -107,7 +107,7 @@ public interface PageManager extends WikiEventListener {
      * @param page The page to check the lock for
      * @return Current lock, or null, if there is no lock
      */
-    PageLock getCurrentLock(WikiPage page);
+    PageLock getCurrentLock( WikiPage page );
 
     /**
      * Returns a list of currently applicable locks.  Note that by the time you get the list,
@@ -126,7 +126,7 @@ public interface PageManager extends WikiEventListener {
      * @return A WikiPage object, or null, if the page does not exist
      * @throws ProviderException If there is something wrong with the page name or the repository
      */
-    WikiPage getPageInfo(String pageName, int version) throws ProviderException;
+    WikiPage getPageInfo( String pageName, int version ) throws ProviderException;
 
     /**
      * Gets a version history of page.  Each element in the returned List is a WikiPage.
@@ -135,7 +135,7 @@ public interface PageManager extends WikiEventListener {
      * @return If the page does not exist, returns null, otherwise a List of WikiPages.
      * @throws ProviderException If the repository fails.
      */
-    List<WikiPage> getVersionHistory(String pageName) throws ProviderException;
+    List<WikiPage> getVersionHistory( String pageName ) throws ProviderException;
 
     /**
      *  Returns the provider name.
@@ -168,7 +168,7 @@ public interface PageManager extends WikiEventListener {
      * @return A boolean value describing the existence of a page
      * @throws ProviderException If the backend fails or the name is illegal.
      */
-    boolean pageExists(String pageName) throws ProviderException;
+    boolean pageExists( String pageName ) throws ProviderException;
 
     /**
      * Checks for existence of a specific page and version.
@@ -179,7 +179,7 @@ public interface PageManager extends WikiEventListener {
      * @throws ProviderException If backend fails or name is illegal
      * @since 2.3.29
      */
-    boolean pageExists(String pageName, int version) throws ProviderException;
+    boolean pageExists( String pageName, int version ) throws ProviderException;
 
     /**
      * Deletes only a specific version of a WikiPage.
@@ -187,7 +187,7 @@ public interface PageManager extends WikiEventListener {
      * @param page The page to delete.
      * @throws ProviderException if the page fails
      */
-    void deleteVersion(WikiPage page) throws ProviderException;
+    void deleteVersion( WikiPage page ) throws ProviderException;
 
     /**
      *  Deletes a page or an attachment completely, including all versions.  If the page does not exist, does nothing.
@@ -195,7 +195,7 @@ public interface PageManager extends WikiEventListener {
      * @param pageName The name of the page.
      * @throws ProviderException If something goes wrong.
      */
-    void deletePage( final String pageName ) throws ProviderException;
+    void deletePage( String pageName ) throws ProviderException;
 
     /**
      * Deletes an entire page, all versions, all traces.
@@ -203,7 +203,7 @@ public interface PageManager extends WikiEventListener {
      * @param page The WikiPage to delete
      * @throws ProviderException If the repository operation fails
      */
-    void deletePage(WikiPage page) throws ProviderException;
+    void deletePage( WikiPage page ) throws ProviderException;
 
     /**
      * Listens for {@link org.apache.wiki.event.WikiSecurityEvent#PROFILE_NAME_CHANGED}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java
index 7e470bb..42df456 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java
@@ -19,16 +19,15 @@
 
 package org.apache.wiki.pages;
 
+import org.apache.log4j.Logger;
+import org.apache.wiki.util.ClassUtil;
+import org.apache.wiki.util.comparators.JavaNaturalComparator;
+
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Properties;
 
-import org.apache.log4j.Logger;
-import org.apache.wiki.util.ClassUtil;
-import org.apache.wiki.util.comparators.JavaNaturalComparator;
-
 /**
  * Wrapper class for managing and using the PageNameComparator.
  * <p>
@@ -53,7 +52,7 @@ public class PageSorter implements Comparator< String > {
      * 
      * @param comparator the Comparator to use
      */
-    public PageSorter( Comparator<String> comparator ) {
+    public PageSorter( final Comparator<String> comparator ) {
         m_comparator = comparator;
     }
 
@@ -66,16 +65,16 @@ public class PageSorter implements Comparator< String > {
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
      */
     @Override
-    public int compare( String pageName1, String pageName2 ) {
+    public int compare( final String pageName1, final String pageName2 ) {
         return m_comparator.compare( pageName1, pageName2 );
     }
 
     @Override
-    public boolean equals( Object o ) {
-        if( !(o instanceof PageSorter) ) {
+    public boolean equals( final Object o ) {
+        if( !( o instanceof PageSorter ) ) {
             return false; // Definitely not equal
         }
-        PageSorter that = (PageSorter) o;
+        final PageSorter that = ( PageSorter )o;
         if( this == that || m_comparator == that.m_comparator ) {
             return true; // Essentially the same object
         }
@@ -91,28 +90,26 @@ public class PageSorter implements Comparator< String > {
      * @param props this WikiEngine's properties.
      */
     @SuppressWarnings( "unchecked" )
-    public void initialize( Properties props ) {
+    public void initialize( final Properties props ) {
         // Default is Java natural order
         m_comparator = JavaNaturalComparator.DEFAULT_JAVA_COMPARATOR;
-        String className = props.getProperty( PROP_PAGE_NAME_COMPARATOR );
+        final String className = props.getProperty( PROP_PAGE_NAME_COMPARATOR );
         if( className != null && className.length() > 0 ) {
             try {
-                m_comparator = (Comparator<String>) ClassUtil.findClass( "org.apache.wiki.util.comparators", className ).newInstance();
-            } catch( Exception e ) {
+                m_comparator = ( Comparator< String > )ClassUtil.findClass( "org.apache.wiki.util.comparators", className ).newInstance();
+            } catch( final Exception e ) {
                 LOG.error( "Falling back to default \"natural\" comparator", e );
             }
         }
     }
 
     /**
-     * Sorts the specified list into ascending order based on the
-     * PageNameComparator. The actual sort is done using
-     * <code>Collections.sort()</code>.
+     * Sorts the specified list into ascending order based on the PageNameComparator. The actual sort is done using {@code List.sort()}.
      * 
      * @param nameList the page names to be sorted
      */
-    public void sort( List< String > nameList ) {
-        Collections.sort( nameList, m_comparator );
+    public void sort( final List< String > nameList ) {
+        nameList.sort( m_comparator );
     }
 
     /**
@@ -122,7 +119,7 @@ public class PageSorter implements Comparator< String > {
      * 
      * @param nameArray the page names to be sorted
      */
-    public void sort( String[] nameArray ) {
+    public void sort( final String[] nameArray ) {
         Arrays.sort( nameArray, m_comparator );
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageTimeComparator.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageTimeComparator.java
index b410bb0..dee1925 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageTimeComparator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageTimeComparator.java
@@ -26,11 +26,9 @@ import java.util.Comparator;
 import java.util.Date;
 
 /**
- *  Compares the lastModified date of its arguments.  Both o1 and o2 MUST
- *  be WikiPage objects, or else you will receive a ClassCastException.
+ *  Compares the lastModified date of its arguments.  Both o1 and o2 MUST be WikiPage objects, or else you will receive a ClassCastException.
  *  <p>
- *  If the lastModified date is the same, then the next key is the page name.
- *  If the page name is also equal, then returns 0 for equality.
+ *  If the lastModified date is the same, then the next key is the page name. If the page name is also equal, then returns 0 for equality.
  */
 public class PageTimeComparator implements Comparator< WikiPage >, Serializable {