Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jan 24, 2022
1 parent 1eb6cee commit 1a5bee5
Show file tree
Hide file tree
Showing 63 changed files with 84 additions and 81 deletions.
7 changes: 4 additions & 3 deletions src/main/java/net/fortuna/ical4j/data/AbstractOutputter.java
Expand Up @@ -31,10 +31,11 @@
*/
package net.fortuna.ical4j.data;

import java.nio.charset.Charset;

import net.fortuna.ical4j.util.CompatibilityHints;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
* Base class for model outputters.
*
Expand All @@ -52,7 +53,7 @@ public abstract class AbstractOutputter {
/**
* The default character set used to generate output.
*/
protected static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
protected static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

private boolean validating;

Expand Down
Expand Up @@ -66,7 +66,7 @@ public class CalendarParserImpl implements CalendarParser {

private static final String UNEXPECTED_TOKEN_MESSAGE = "Expected [{0}], read [{1}]";

private Logger log = LoggerFactory.getLogger(CalendarParserImpl.class);
private final Logger log = LoggerFactory.getLogger(CalendarParserImpl.class);

private final ComponentListParser componentListParser = new ComponentListParser();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/data/ParserException.java
Expand Up @@ -47,7 +47,7 @@ public class ParserException extends Exception {

private static final String ERROR_MESSAGE_PATTERN = "Error at line {0}:";

private int lineNo;
private final int lineNo;

/**
* @param lineNo line number where parsing error ocurred
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/fortuna/ical4j/data/UnfoldingReader.java
Expand Up @@ -56,7 +56,7 @@
*/
public class UnfoldingReader extends PushbackReader {

private Logger log = LoggerFactory.getLogger(UnfoldingReader.class);
private final Logger log = LoggerFactory.getLogger(UnfoldingReader.class);

/**
* The pattern used to identify a fold in an iCalendar data stream.
Expand All @@ -78,9 +78,9 @@ public class UnfoldingReader extends PushbackReader {
*/
private static final char[] RELAXED_FOLD_PATTERN_2 = {'\n', '\t'};

private char[][] patterns;
private final char[][] patterns;

private char[][] buffers;
private final char[][] buffers;

private int linesUnfolded;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/filter/Filter.java
Expand Up @@ -71,7 +71,7 @@ public class Filter<T> {

private List<Predicate<T>> rules;

private int type;
private final int type;

/**
* @param rules one or more rules that are applied by this filter
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/filter/FilterTarget.java
Expand Up @@ -83,7 +83,7 @@ public int hashCode() {

public static class Attribute {

private String name;
private final String name;

private String value;

Expand Down
Expand Up @@ -58,7 +58,7 @@ public boolean test(Property t) {
*/
public static class ParameterExists implements Comparable<Parameter> {

private Parameter specification;
private final Parameter specification;

public ParameterExists(Parameter specification) {
this.specification = specification;
Expand Down
Expand Up @@ -47,7 +47,7 @@
*/
public class PeriodRule<T extends Component> implements Predicate<T> {

private Period period;
private final Period period;

/**
* Constructs a new instance using the specified period.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/AddressList.java
Expand Up @@ -54,7 +54,7 @@ public class AddressList implements Serializable, Iterable<URI> {

private static final long serialVersionUID = 81383256078213569L;

private List<URI> addresses;
private final List<URI> addresses;

/**
* Default constructor.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/fortuna/ical4j/model/ComponentBuilder.java
Expand Up @@ -11,9 +11,9 @@ public class ComponentBuilder<T extends Component> extends AbstractContentBuilde

private String name;

private PropertyList<Property> properties = new PropertyList<>();
private final PropertyList<Property> properties = new PropertyList<>();

private ComponentList<Component> subComponents = new ComponentList<>();
private final ComponentList<Component> subComponents = new ComponentList<>();

public ComponentBuilder() {
this(true);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/ComponentList.java
Expand Up @@ -76,7 +76,7 @@ public ComponentList(ComponentList<? extends T> components) throws ParseExceptio
IOException, URISyntaxException {

for (T c : components) {
add((T) c.copy());
add(c.copy());
}
}

Expand Down
Expand Up @@ -43,7 +43,7 @@
*/
public class IndexedComponentList<T extends Component> {

private Map<String, List<T>> index;
private final Map<String, List<T>> index;

/**
* Creates a new instance indexed on properties with the specified name.
Expand Down
Expand Up @@ -47,7 +47,7 @@ public class IndexedPropertyList {

private static final PropertyList<Property> EMPTY_LIST = new PropertyList<Property>();

private Map<String, PropertyList<Property>> index;
private final Map<String, PropertyList<Property>> index;

/**
* Creates a new instance indexed on the parameters with the specified name.
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/fortuna/ical4j/model/Iso8601.java
Expand Up @@ -31,13 +31,13 @@
*/
package net.fortuna.ical4j.model;

import java.text.DateFormat;
import java.util.Date;

import net.fortuna.ical4j.util.CompatibilityHints;
import net.fortuna.ical4j.util.Dates;
import net.fortuna.ical4j.util.TimeZones;

import java.text.DateFormat;
import java.util.Date;

/**
* $Id$
*
Expand All @@ -57,11 +57,11 @@ public abstract class Iso8601 extends Date {
private static final long serialVersionUID = -4290728005713946811L;
private static final java.util.TimeZone GMT = TimeZone.getTimeZone(TimeZones.GMT_ID);

private DateFormat format;
private final DateFormat format;

private DateFormat gmtFormat;

private int precision;
private final int precision;

/**
* @param time a time value in milliseconds
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class LocationTypeList implements Serializable, Iterable<String> {

private static final long serialVersionUID = -9181735547604179160L;

private List<String> locationTypes;
private final List<String> locationTypes;

/**
* Default constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/Parameter.java
Expand Up @@ -220,7 +220,7 @@ public abstract class Parameter extends Content implements Comparable<Parameter>
*/
public static final String EXPERIMENTAL_PREFIX = "X-";

private String name;
private final String name;

private final ParameterFactory factory;

Expand Down
Expand Up @@ -22,7 +22,7 @@ public class PropertyBuilder extends AbstractContentBuilder {

private String value;

private ParameterList parameters = new ParameterList();
private final ParameterList parameters = new ParameterList();

public PropertyBuilder() {
this(new ArrayList<>());
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/fortuna/ical4j/model/Recur.java
Expand Up @@ -93,7 +93,7 @@ public class Recur implements Serializable {
private static final String SKIP = "SKIP";

public enum Frequency {
SECONDLY, MINUTELY, HOURLY, DAILY, WEEKLY, MONTHLY, YEARLY;
SECONDLY, MINUTELY, HOURLY, DAILY, WEEKLY, MONTHLY, YEARLY
}

public enum RScale {
Expand Down Expand Up @@ -121,7 +121,7 @@ public String getChronology() {
}

public enum Skip {
OMIT, BACKWARD, FORWARD;
OMIT, BACKWARD, FORWARD
}

/**
Expand Down Expand Up @@ -181,7 +181,7 @@ public enum Skip {
*/
public static final String KEY_MAX_INCREMENT_COUNT = "net.fortuna.ical4j.recur.maxincrementcount";

private static int maxIncrementCount;
private static final int maxIncrementCount;

static {
maxIncrementCount = Configurator.getIntProperty(KEY_MAX_INCREMENT_COUNT).orElse(1000);
Expand Down Expand Up @@ -225,7 +225,7 @@ public enum Skip {

private int calendarWeekStartDay;

private Map<String, String> experimentalValues = new HashMap<String, String>();
private final Map<String, String> experimentalValues = new HashMap<String, String>();

// Calendar field we increment based on frequency.
private int calIncField;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/TextList.java
Expand Up @@ -52,7 +52,7 @@ public class TextList implements Serializable, Iterable<String> {

private static final long serialVersionUID = -417427815871330636L;

private List<String> texts;
private final List<String> texts;

/**
* Default constructor.
Expand Down
Expand Up @@ -54,7 +54,7 @@ public abstract class TimeZoneRegistryFactory {
*/
public static final String KEY_FACTORY_CLASS = "net.fortuna.ical4j.timezone.registry";

private static TimeZoneRegistryFactory instance;
private static final TimeZoneRegistryFactory instance;
static {
Optional<TimeZoneRegistryFactory> property = Configurator.getObjectProperty(KEY_FACTORY_CLASS);
instance = property.orElse(new DefaultTimeZoneRegistryFactory());
Expand Down
Expand Up @@ -107,7 +107,7 @@ public class TimeZoneRegistryImpl implements TimeZoneRegistry {

private final TimeZoneLoader timeZoneLoader;

private Map<String, TimeZone> timezones;
private final Map<String, TimeZone> timezones;

private final boolean lenientTzResolution;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/fortuna/ical4j/model/WeekDay.java
Expand Up @@ -89,9 +89,9 @@ public class WeekDay implements Serializable {

public enum Day { SU, MO, TU, WE, TH, FR, SA }

private Day day;
private final Day day;

private int offset;
private final int offset;

/**
* @param value a string representation of a week day
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/fortuna/ical4j/model/component/VEvent.java
Expand Up @@ -343,7 +343,7 @@ public final void validate(final boolean recurse) throws ValidationException {
&& !Status.VEVENT_CONFIRMED.getValue().equals(status.getValue())
&& !Status.VEVENT_CANCELLED.getValue().equals(status.getValue())) {
result.getErrors().add("Status property ["
+ status.toString() + "] is not applicable for VEVENT");
+ status + "] is not applicable for VEVENT");
}

if (getProperty(Property.DTEND) != null) {
Expand Down Expand Up @@ -462,7 +462,7 @@ public final VEvent getOccurrence(final Date date) throws IOException,
final PeriodList consumedTime = getConsumedTime(date, date);
for (final Period p : consumedTime) {
if (p.getStart().equals(date)) {
final VEvent occurrence = (VEvent) this.copy();
final VEvent occurrence = this.copy();
occurrence.getProperties().add(new RecurrenceId(date));
return occurrence;
}
Expand Down
Expand Up @@ -255,7 +255,7 @@ public final void validate(final boolean recurse) throws ValidationException {
&& !Status.VTODO_IN_PROCESS.getValue().equals(status.getValue())
&& !Status.VTODO_CANCELLED.getValue().equals(status.getValue())) {
throw new ValidationException("Status property ["
+ status.toString() + "] may not occur in VTODO");
+ status + "] may not occur in VTODO");
}

if (recurse) {
Expand Down
Expand Up @@ -51,7 +51,7 @@ public class Abbrev extends Parameter implements Encodable {

private static final long serialVersionUID = -8650841407406422738L;

private String value;
private final String value;

/**
* @param aValue a string abbreviation
Expand Down
Expand Up @@ -52,7 +52,7 @@ public class AltRep extends Parameter implements Encodable {

private static final long serialVersionUID = -2445932592596993470L;

private URI uri;
private final URI uri;

/**
* @param aValue a string representation of an alternate text represenation
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/parameter/Cn.java
Expand Up @@ -50,7 +50,7 @@ public class Cn extends Parameter implements Encodable {

private static final long serialVersionUID = -8087119055007093293L;

private String value;
private final String value;

/**
* @param aValue a string representation of a Common Name
Expand Down
Expand Up @@ -85,7 +85,7 @@ public class CuType extends Parameter implements Encodable {
*/
public static final CuType UNKNOWN = new CuType(VALUE_UNKNOWN);

private String value;
private final String value;

/**
* @param aValue a string representation of a Calendar User Type
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class DelegatedFrom extends Parameter {

private static final long serialVersionUID = -795956139235258568L;

private AddressList delegators;
private final AddressList delegators;

/**
* @param aValue a string representation of Delegators
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class DelegatedTo extends Parameter {

private static final long serialVersionUID = 567577003350648021L;

private AddressList delegatees;
private final AddressList delegatees;

/**
* @param aValue a string representation of Delegatees
Expand Down
Expand Up @@ -61,7 +61,7 @@ public class Derived extends Parameter {
*/
public static final Derived FALSE = new Derived(VALUE_FALSE);

private Boolean value;
private final Boolean value;

/**
* @param aValue a string representation
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/parameter/Dir.java
Expand Up @@ -52,7 +52,7 @@ public class Dir extends Parameter implements Encodable {

private static final long serialVersionUID = -8581904779721020689L;

private URI uri;
private final URI uri;

/**
* @param aValue a string representation of a directory entry reference
Expand Down
Expand Up @@ -58,7 +58,7 @@ public class Display extends Parameter implements Encodable {
private static final String PARAMETER_NAME = "DISPLAY";

public enum Value {
BADGE, GRAPHIC, FULLSIZE, THUMBNAIL;
BADGE, GRAPHIC, FULLSIZE, THUMBNAIL
}

private final String[] values;
Expand Down
Expand Up @@ -126,7 +126,7 @@ public class Encoding extends Parameter implements Encodable {
*/
public static final Encoding BASE64 = new Encoding(VALUE_BASE64);

private String value;
private final String value;

/**
* @param aValue a string representation of an Inline Encoding
Expand Down

0 comments on commit 1a5bee5

Please sign in to comment.