From 7b02ad13a804c8b7dcbd3017efa454537193e4ee Mon Sep 17 00:00:00 2001 From: Miroslav Pokorny Date: Sat, 21 Sep 2024 11:36:24 +1000 Subject: [PATCH] SpreadsheetMetadata.checkPropertyName refactor --- .../spreadsheet/meta/SpreadsheetMetadata.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/walkingkooka/spreadsheet/meta/SpreadsheetMetadata.java b/src/main/java/walkingkooka/spreadsheet/meta/SpreadsheetMetadata.java index 550b11c1d..7752eb865 100644 --- a/src/main/java/walkingkooka/spreadsheet/meta/SpreadsheetMetadata.java +++ b/src/main/java/walkingkooka/spreadsheet/meta/SpreadsheetMetadata.java @@ -220,9 +220,9 @@ public Optional name() { * require creating a new {@link SpreadsheetMetadata}. */ public final Optional get(final SpreadsheetMetadataPropertyName propertyName) { - checkPropertyName(propertyName); - - return this.getOrGetDefaults(propertyName); + return this.getOrGetDefaults( + checkPropertyName(propertyName) + ); } /** @@ -324,9 +324,8 @@ private TextStyle getStyleOrEmpty() { */ public final SpreadsheetMetadata set(final SpreadsheetMetadataPropertyName propertyName, final V value) { - checkPropertyName(propertyName); return this.set0( - propertyName, + checkPropertyName(propertyName), propertyName.checkValue(value) // necessary because absolute references values are made relative ); } @@ -418,15 +417,15 @@ private static void reportDuplicateProperty(final SpreadsheetMetadataPropertyNam * Removes a possibly existing property returning a {@link SpreadsheetMetadata} without. */ public final SpreadsheetMetadata remove(final SpreadsheetMetadataPropertyName propertyName) { - checkPropertyName(propertyName); - - return this.remove0(propertyName); + return this.remove0( + checkPropertyName(propertyName) + ); } abstract SpreadsheetMetadata remove0(final SpreadsheetMetadataPropertyName propertyName); - private static void checkPropertyName(final SpreadsheetMetadataPropertyName propertyName) { - Objects.requireNonNull(propertyName, "propertyName"); + private static SpreadsheetMetadataPropertyName checkPropertyName(final SpreadsheetMetadataPropertyName propertyName) { + return Objects.requireNonNull(propertyName, "propertyName"); } // setOrRemove......................................................................................................