LOG4J2-435 renamed fields and parameters

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/34e34855
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/34e34855
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/34e34855

Branch: refs/heads/master
Commit: 34e3485570f35ef774b0af284f1da5eca7f32d0f
Parents: e11e58c
Author: rpopma <[email protected]>
Authored: Thu Nov 26 23:52:26 2015 +0900
Committer: rpopma <[email protected]>
Committed: Thu Nov 26 23:52:26 2015 +0900

----------------------------------------------------------------------
 .../appender/rolling/action/IfLastModified.java | 43 +++++++++++---------
 .../rolling/action/IfLastModifiedTest.java      | 10 ++---
 2 files changed, 29 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/34e34855/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
index e5019a9..064f702 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
@@ -30,55 +30,60 @@ import org.apache.logging.log4j.core.util.ClockFactory;
 import org.apache.logging.log4j.status.StatusLogger;
 
 /**
- * PathFilter that accepts paths that are older than the specified duration.
+ * PathCondition that accepts paths that are older than the specified duration.
  */
 @Plugin(name = "IfLastModified", category = "Core", printObject = true)
 public final class IfLastModified implements PathCondition {
     private static final Logger LOGGER = StatusLogger.getLogger();
     private static final Clock CLOCK = ClockFactory.getClock();
 
-    private final Duration duration;
+    private final Duration age;
 
-    private IfLastModified(final Duration duration) {
-        this.duration = Objects.requireNonNull(duration, "duration");
+    private IfLastModified(final Duration age) {
+        this.age = Objects.requireNonNull(age, "age");
     }
 
-    public Duration getDuration() {
-        return duration;
+    public Duration getAge() {
+        return age;
     }
 
     /*
      * (non-Javadoc)
-     * 
-     * @see 
org.apache.logging.log4j.core.appender.rolling.action.PathFilter#accept(java.nio.file.Path,
-     * java.nio.file.Path)
+     * @see 
org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path,
 java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes)
      */
     @Override
     public boolean accept(final Path baseDir, final Path relativePath, final 
BasicFileAttributes attrs) {
         final FileTime fileTime = attrs.lastModifiedTime();
         final long millis = fileTime.toMillis();
         final long ageMillis = CLOCK.currentTimeMillis() - millis;
-        final boolean result = ageMillis >= duration.toMillis();
+        final boolean result = ageMillis >= age.toMillis();
         final String match = result ? ">=" : "<";
-        LOGGER.trace("LastModifiedFilter: {} ageMillis '{}' {} duration '{}'", 
relativePath, ageMillis, match,
-                duration);
+        LOGGER.trace("IfLastModified: {} ageMillis '{}' {} '{}'", 
relativePath, ageMillis, match, age);
         return result;
     }
 
+    /*
+     * (non-Javadoc)
+     * @see 
org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk()
+     */
+    @Override
+    public void beforeFileTreeWalk() {
+    }
+
     /**
-     * Create a FileLastModifiedFilter filter.
+     * Create an IfLastModified condition.
      * 
-     * @param duration The path age that is accepted by this filter. Must be a 
valid Duration.
-     * @return A FileLastModifiedFilter filter.
+     * @param age The path age that is accepted by this condition. Must be a 
valid Duration.
+     * @return An IfLastModified condition.
      */
     @PluginFactory
-    public static IfLastModified createAgeFilter( //
-            @PluginAttribute("duration") final Duration duration) {
-        return new IfLastModified(duration);
+    public static IfLastModified createAgeCondition( //
+            @PluginAttribute("age") final Duration age) {
+        return new IfLastModified(age);
     }
 
     @Override
     public String toString() {
-        return "FileLastModifiedFilter(age=" + duration + ")";
+        return "IfLastModified(age=" + age + ")";
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/34e34855/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
index 90f6fdb..b23ca68 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
@@ -32,13 +32,13 @@ public class IfLastModifiedTest {
 
     @Test
     public void testGetDurationReturnsConstructorValue() {
-        IfLastModified filter = 
IfLastModified.createAgeFilter(Duration.parse("P7D"));
-        assertEquals(0, filter.getDuration().compareTo(Duration.parse("P7D")));
+        IfLastModified filter = 
IfLastModified.createAgeCondition(Duration.parse("P7D"));
+        assertEquals(0, filter.getAge().compareTo(Duration.parse("P7D")));
     }
 
     @Test
     public void testAcceptsIfFileAgeEqualToDuration() {
-        IfLastModified filter = 
IfLastModified.createAgeFilter(Duration.parse("PT33S"));
+        IfLastModified filter = 
IfLastModified.createAgeCondition(Duration.parse("PT33S"));
         DummyFileAttributes attrs = new DummyFileAttributes();
         final long age = 33 * 1000;
         attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - 
age);
@@ -47,7 +47,7 @@ public class IfLastModifiedTest {
 
     @Test
     public void testAcceptsIfFileAgeExceedsDuration() {
-        IfLastModified filter = 
IfLastModified.createAgeFilter(Duration.parse("PT33S"));
+        IfLastModified filter = 
IfLastModified.createAgeCondition(Duration.parse("PT33S"));
         DummyFileAttributes attrs = new DummyFileAttributes();
         final long age = 33 * 1000 + 5;
         attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - 
age);
@@ -56,7 +56,7 @@ public class IfLastModifiedTest {
 
     @Test
     public void testDoesNotAcceptIfFileAgeLessThanDuration() {
-        IfLastModified filter = 
IfLastModified.createAgeFilter(Duration.parse("PT33S"));
+        IfLastModified filter = 
IfLastModified.createAgeCondition(Duration.parse("PT33S"));
         DummyFileAttributes attrs = new DummyFileAttributes();
         final long age = 33 * 1000 - 5;
         attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - 
age);

Reply via email to