org.apache.sling.settings.impl.SlingOptionsReadResult Maven / Gradle / Ivy
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
package org.apache.sling.settings.impl;
import java.util.Objects;
/**
* The SlingOptions read operation result.
*/
public class SlingOptionsReadResult {
private final RunModes runModes;
/**
* Create a SlingOptions read result that indicated successful read of the RunModes object.
*
* @param runModes the not null runModes reference that will be served to the client of this class
*/
public SlingOptionsReadResult(final RunModes runModes) {
this.runModes = Objects.requireNonNull(runModes);
}
/**
* Create an empty read result that indicates the SlingOptions object is not present.
* This will indicate to this object caller that there was a failure, error of any type
* that prevented to read the SlingOptions object.
*/
public SlingOptionsReadResult() {
this.runModes = null;
}
/**
* Get the Sling run modes object if present. If it is not present and wasn't correctly read
* then this method will return {@linkplain IllegalStateException}.
*
* Note: Prior using this method make sure the read result was successful using the
* {@linkplain #isSuccessful()} function.
*
* @return always the SlingRunModes object reference
* @throws IllegalStateException in case object is not present.
*/
public RunModes getRunModes() {
if (runModes == null) {
throw new IllegalStateException("Sling RunModes are not available as read was not successful");
}
return runModes;
}
/**
* Indicates if the SlingOptions object was correctly read and is present.
*
* @return true if it is present otherwise false in case of read, process failure
*/
public boolean isSuccessful() {
return runModes != null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy