Skip to content

Commit c0ba7b5

Browse files
author
James Hagborg
committed
Make methods internal to preferences protected
1 parent bc2e13a commit c0ba7b5

File tree

6 files changed

+54
-50
lines changed

6 files changed

+54
-50
lines changed

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ test {
5353
}
5454
}
5555

56+
javadoc {
57+
options.addBooleanOption('html5', true)
58+
}
59+
5660
task sourcesJar(type: Jar, dependsOn: classes) {
5761
description 'Builds a jar file full of sources.'
5862
classifier = 'sources'

src/main/java/org/hyperonline/hyperlib/pref/BooleanPreference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public BooleanPreference(String name, boolean value) {
3232
* {@inheritDoc}
3333
*/
3434
@Override
35-
public synchronized boolean hasChanged() {
35+
protected synchronized boolean hasChanged() {
3636
boolean newValue = get();
3737
boolean changed = newValue != m_lastValue;
3838
m_lastValue = newValue;
@@ -43,7 +43,7 @@ public synchronized boolean hasChanged() {
4343
* {@inheritDoc}
4444
*/
4545
@Override
46-
public void putDefaultValue() {
46+
protected void putDefaultValue() {
4747
Preferences.getInstance().putBoolean(getName(), m_default);
4848
}
4949

src/main/java/org/hyperonline/hyperlib/pref/DoublePreference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public DoublePreference(String name, double value) {
3232
* {@inheritDoc}
3333
*/
3434
@Override
35-
public synchronized boolean hasChanged() {
35+
protected synchronized boolean hasChanged() {
3636
double newValue = get();
3737
boolean changed = newValue != m_lastValue;
3838
m_lastValue = newValue;
@@ -43,7 +43,7 @@ public synchronized boolean hasChanged() {
4343
* {@inheritDoc}
4444
*/
4545
@Override
46-
public void putDefaultValue() {
46+
protected void putDefaultValue() {
4747
Preferences.getInstance().putDouble(getName(), m_default);
4848
}
4949

src/main/java/org/hyperonline/hyperlib/pref/IntPreference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public IntPreference(String name, int value) {
3232
* {@inheritDoc}
3333
*/
3434
@Override
35-
public synchronized boolean hasChanged() {
35+
protected synchronized boolean hasChanged() {
3636
int newValue = get();
3737
boolean changed = newValue != m_lastValue;
3838
m_lastValue = newValue;
@@ -43,7 +43,7 @@ public synchronized boolean hasChanged() {
4343
* {@inheritDoc}
4444
*/
4545
@Override
46-
public void putDefaultValue() {
46+
protected void putDefaultValue() {
4747
Preferences.getInstance().putInt(getName(), m_default);
4848
}
4949

src/main/java/org/hyperonline/hyperlib/pref/Preference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public synchronized void putDefaultIfEmpty() {
6262
*
6363
* @return true if the value has changed, false otherwise
6464
*/
65-
abstract boolean hasChanged();
65+
protected abstract boolean hasChanged();
6666

6767
/**
6868
* Put an entry with the default value.
6969
*/
70-
abstract void putDefaultValue();
70+
protected abstract void putDefaultValue();
7171
}

src/main/java/org/hyperonline/hyperlib/pref/ScalarPreference.java

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,52 @@
1313
*/
1414
public class ScalarPreference {
1515

16-
private List<DoublePreference> m_prefs = new ArrayList<>();
16+
private List<DoublePreference> m_prefs = new ArrayList<>();
1717

18-
/**
19-
* Construct a scalar preference with the given name and components.
20-
*
21-
* @param name
22-
* The name of the preferences object.
23-
* @param components
24-
* A sequence of letters indicating the components. For example,
25-
* "RGB", "HSV", "XYZ", etc. It may be any length.
26-
* @param defaults
27-
* Default settings for components
28-
*/
29-
public ScalarPreference(String name, String components, double... defaults) {
30-
if (defaults.length != components.length()) {
31-
throw new IllegalArgumentException("Components and defaults have different lengths");
32-
}
18+
/**
19+
* Construct a scalar preference with the given name and components.
20+
*
21+
* @param name
22+
* The name of the preferences object.
23+
* @param components
24+
* A sequence of letters indicating the components. For example,
25+
* "RGB", "HSV", "XYZ", etc. It may be any length.
26+
* @param defaults
27+
* Default settings for components
28+
*/
29+
public ScalarPreference(String name, String components, double... defaults) {
30+
if (defaults.length != components.length()) {
31+
throw new IllegalArgumentException("Components and defaults have different lengths");
32+
}
3333

34-
for (int i = 0; i < defaults.length; i++) {
35-
String childName = name + PreferencesSet.SEPARATOR + components.charAt(i);
36-
m_prefs.add(new DoublePreference(childName, defaults[i]));
37-
}
38-
}
34+
for (int i = 0; i < defaults.length; i++) {
35+
String childName = name + PreferencesSet.SEPARATOR + components.charAt(i);
36+
m_prefs.add(new DoublePreference(childName, defaults[i]));
37+
}
38+
}
3939

40-
/**
41-
* Construct a scalar preference, while also updating the right info inside the
42-
* parent set.
43-
*/
44-
ScalarPreference(PreferencesSet parent, String name, String components, double[] defaults) {
45-
if (defaults.length != components.length()) {
46-
throw new IllegalArgumentException("Components and defaults have different lengths");
47-
}
40+
/**
41+
* Construct a scalar preference, while also updating the right info inside
42+
* the parent set.
43+
*/
44+
ScalarPreference(PreferencesSet parent, String name, String components, double[] defaults) {
45+
if (defaults.length != components.length()) {
46+
throw new IllegalArgumentException("Components and defaults have different lengths");
47+
}
4848

49-
for (int i = 0; i < defaults.length; i++) {
50-
String childName = name + PreferencesSet.SEPARATOR + components.charAt(i);
51-
m_prefs.add(parent.addDouble(childName, defaults[i]));
52-
}
53-
}
49+
for (int i = 0; i < defaults.length; i++) {
50+
String childName = name + PreferencesSet.SEPARATOR + components.charAt(i);
51+
m_prefs.add(parent.addDouble(childName, defaults[i]));
52+
}
53+
}
5454

55-
/**
56-
* Get the current value of the preference.
57-
*
58-
* @return The current value of the preference.
59-
*/
60-
public Scalar get() {
61-
return new Scalar(m_prefs.stream().mapToDouble(DoublePreference::get).toArray());
62-
}
55+
/**
56+
* Get the current value of the preference.
57+
*
58+
* @return The current value of the preference.
59+
*/
60+
public Scalar get() {
61+
return new Scalar(m_prefs.stream().mapToDouble(DoublePreference::get).toArray());
62+
}
6363

6464
}

0 commit comments

Comments
 (0)