Upgrade to bld 1.7.1
This commit is contained in:
parent
3a0144ea07
commit
0cf1c230d4
9 changed files with 113 additions and 110 deletions
|
@ -26,6 +26,7 @@ import java.util.function.IntFunction;
|
|||
* @author <a href="https://github.com/gbevin">Geert Bevin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
@SuppressWarnings("PMD.DataClass")
|
||||
public class EntryBase {
|
||||
private IntFunction<Integer> calc;
|
||||
private Object defaultValue;
|
||||
|
@ -53,13 +54,6 @@ public class EntryBase {
|
|||
return calc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the calculation function.
|
||||
*/
|
||||
protected void setCalc(IntFunction<Integer> calc) {
|
||||
this.calc = calc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default value.
|
||||
*/
|
||||
|
@ -67,15 +61,6 @@ public class EntryBase {
|
|||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the initial value to set the {@link java.util.Properties property} to, if not already defined.
|
||||
*
|
||||
* @param defaultValue the default value
|
||||
*/
|
||||
protected void setDefaultValue(Object defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key of the {@link java.util.Properties property}.
|
||||
*/
|
||||
|
@ -83,15 +68,6 @@ public class EntryBase {
|
|||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key of the {@link java.util.Properties property}.
|
||||
*
|
||||
* @param key the {@link java.util.Properties property} key
|
||||
*/
|
||||
protected void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the modify function.
|
||||
*/
|
||||
|
@ -99,13 +75,6 @@ public class EntryBase {
|
|||
return modify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the modify function.
|
||||
*/
|
||||
protected void setModify(BiFunction<String, String, String> modify) {
|
||||
this.modify = modify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value to be used in the {@link #modify} function.
|
||||
*/
|
||||
|
@ -113,15 +82,6 @@ public class EntryBase {
|
|||
return modifyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the modify value.
|
||||
*
|
||||
* @param value the modify value.
|
||||
*/
|
||||
protected void setModifyValue(String value) {
|
||||
this.modifyValue = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new value to set the {@link java.util.Properties property)} to.
|
||||
*/
|
||||
|
@ -129,15 +89,6 @@ public class EntryBase {
|
|||
return newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new value for {@link java.util.Properties property}.
|
||||
*
|
||||
* @param newValue the new value
|
||||
*/
|
||||
public void setNewValue(Object newValue) {
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pattern.
|
||||
*/
|
||||
|
@ -145,16 +96,6 @@ public class EntryBase {
|
|||
return pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link java.text.DecimalFormat DecimalFormat} or {@link java.time.format.DateTimeFormatter DateTimeFormatter}
|
||||
* pattern to be used with {@link EntryDate} or {@link EntryInt} respectively.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
*/
|
||||
protected void setPattern(String pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link EntryDate.Units unit}.
|
||||
*/
|
||||
|
@ -162,15 +103,6 @@ public class EntryBase {
|
|||
return unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link EntryDate.Units unit} value to apply to calculations.
|
||||
*
|
||||
* @param unit the {@link EntryDate.Units unit}
|
||||
*/
|
||||
protected void setUnit(EntryDate.Units unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the {@link java.util.Properties property} is to be deleted.
|
||||
*/
|
||||
|
@ -178,13 +110,6 @@ public class EntryBase {
|
|||
return isDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the {@link java.util.Properties property} should be deleted.
|
||||
*/
|
||||
protected void setDelete(boolean delete) {
|
||||
isDelete = delete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key of the {@link java.util.Properties property}.
|
||||
*
|
||||
|
@ -196,6 +121,45 @@ public class EntryBase {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the calculation function.
|
||||
*/
|
||||
protected void setCalc(IntFunction<Integer> calc) {
|
||||
this.calc = calc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the initial value to set the {@link java.util.Properties property} to, if not already defined.
|
||||
*
|
||||
* @param defaultValue the default value
|
||||
*/
|
||||
protected void setDefaultValue(Object defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the {@link java.util.Properties property} should be deleted.
|
||||
*/
|
||||
protected void setDelete(boolean delete) {
|
||||
isDelete = delete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key of the {@link java.util.Properties property}.
|
||||
*
|
||||
* @param key the {@link java.util.Properties property} key
|
||||
*/
|
||||
protected void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the modify function.
|
||||
*/
|
||||
protected void setModify(BiFunction<String, String, String> modify) {
|
||||
this.modify = modify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the modify function.
|
||||
*
|
||||
|
@ -205,4 +169,41 @@ public class EntryBase {
|
|||
this.modifyValue = value;
|
||||
this.modify = modify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the modify value.
|
||||
*
|
||||
* @param value the modify value.
|
||||
*/
|
||||
protected void setModifyValue(String value) {
|
||||
this.modifyValue = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new value for {@link java.util.Properties property}.
|
||||
*
|
||||
* @param newValue the new value
|
||||
*/
|
||||
public void setNewValue(Object newValue) {
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link java.text.DecimalFormat DecimalFormat} or {@link java.time.format.DateTimeFormatter DateTimeFormatter}
|
||||
* pattern to be used with {@link EntryDate} or {@link EntryInt} respectively.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
*/
|
||||
protected void setPattern(String pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link EntryDate.Units unit} value to apply to calculations.
|
||||
*
|
||||
* @param unit the {@link EntryDate.Units unit}
|
||||
*/
|
||||
protected void setUnit(EntryDate.Units unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.text.DecimalFormat;
|
|||
import java.text.ParseException;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
@ -95,11 +94,11 @@ public final class PropertyFileUtils {
|
|||
* @param p the {@link Properties property}
|
||||
* @param entry the {@link Entry} containing the {@link Properties property} edits
|
||||
*/
|
||||
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
|
||||
@SuppressWarnings({"PMD.SignatureDeclareThrowsException", "PMD.ExceptionAsFlowControl"})
|
||||
public static boolean processDate(String command, Properties p, EntryDate entry, boolean failOnWarning)
|
||||
throws Exception {
|
||||
var success = true;
|
||||
var value = PropertyFileUtils.currentValue(null, entry.getDefaultValue(),
|
||||
var value = currentValue(null, entry.getDefaultValue(),
|
||||
entry.getNewValue());
|
||||
|
||||
var pattern = entry.getPattern();
|
||||
|
@ -159,19 +158,19 @@ public final class PropertyFileUtils {
|
|||
} else if (value instanceof ZonedDateTime) {
|
||||
if (offset != 0) {
|
||||
if (unit == EntryDate.Units.DAY) {
|
||||
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.DAYS);
|
||||
value = ((ZonedDateTime) value).plusDays(offset);
|
||||
} else if (unit == EntryDate.Units.MONTH) {
|
||||
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.MONTHS);
|
||||
value = ((ZonedDateTime) value).plusMonths(offset);
|
||||
} else if (unit == EntryDate.Units.WEEK) {
|
||||
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.WEEKS);
|
||||
value = ((ZonedDateTime) value).plusWeeks(offset);
|
||||
} else if (unit == EntryDate.Units.YEAR) {
|
||||
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.YEARS);
|
||||
value = ((ZonedDateTime) value).plusYears(offset);
|
||||
} else if (unit == EntryDate.Units.SECOND) {
|
||||
value = ((ZonedDateTime) value).plusSeconds(offset);
|
||||
} else if (unit == EntryDate.Units.MINUTE) {
|
||||
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.MINUTES);
|
||||
value = ((ZonedDateTime) value).plusMinutes(offset);
|
||||
} else if (unit == EntryDate.Units.HOUR) {
|
||||
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.HOURS);
|
||||
value = ((ZonedDateTime) value).plusHours(offset);
|
||||
}
|
||||
}
|
||||
parsedValue = dtf.format((ZonedDateTime) value);
|
||||
|
@ -204,7 +203,7 @@ public final class PropertyFileUtils {
|
|||
int intValue = 0;
|
||||
try {
|
||||
var fmt = new DecimalFormat(entry.getPattern());
|
||||
var value = PropertyFileUtils.currentValue(p.getProperty(entry.getKey()), entry.getDefaultValue(),
|
||||
var value = currentValue(p.getProperty(entry.getKey()), entry.getDefaultValue(),
|
||||
entry.getNewValue());
|
||||
|
||||
if (value != null) {
|
||||
|
@ -231,8 +230,7 @@ public final class PropertyFileUtils {
|
|||
* @param entry the {@link Entry} containing the {@link Properties property} edits
|
||||
*/
|
||||
public static boolean processString(Properties p, Entry entry) {
|
||||
var value = PropertyFileUtils.currentValue(p.getProperty(entry.getKey()), entry.getDefaultValue(),
|
||||
entry.getNewValue());
|
||||
var value = currentValue(p.getProperty(entry.getKey()), entry.getDefaultValue(), entry.getNewValue());
|
||||
|
||||
p.setProperty(entry.getKey(), String.valueOf(value));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue