All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.expansion.ExpansionModel Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.expansion;

import io.sphere.sdk.models.Base;

import javax.annotation.Nullable;
import java.util.Optional;

import static org.apache.commons.lang3.StringUtils.isEmpty;

public class ExpansionModel extends Base {
    @Nullable
    protected final String parentPath;
    @Nullable
    protected final String path;

    protected ExpansionModel(@Nullable final String parentPath, @Nullable final String path) {
        this.parentPath = parentPath;
        this.path = path;
    }

    public ExpansionModel() {
        this(null, null);
    }

    protected final String buildPathExpression() {
        return Optional.ofNullable(parentPath).filter(p -> !isEmpty(p)).map(p -> p + ".").orElse("") + Optional.ofNullable(path).orElse("");
    }

    @Nullable
    protected final String pathExpression() {
        return buildPathExpression();
    }

    protected final ExpansionPath expansionPath(final String path) {
        return new ExpandedModel<>(buildPathExpression(), path);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy