org.apache.sling.distribution.packaging.DistributionPackageInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aem-sdk-api Show documentation
Show all versions of aem-sdk-api Show documentation
The Adobe Experience Manager SDK
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.sling.distribution.packaging;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
import org.apache.sling.distribution.DistributionRequestType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
/**
* Additional information about a package.
* Additional information is optional and components should expect every piece of it to be null.
*/
@ProviderType
public final class DistributionPackageInfo extends ValueMapDecorator implements ValueMap {
/**
* distribution package type
*/
public static final String PROPERTY_PACKAGE_TYPE = "package.type";
/**
* distribution request paths
*/
public static final String PROPERTY_REQUEST_PATHS = "request.paths";
/**
* distribution request deep paths
*/
public static final String PROPERTY_REQUEST_DEEP_PATHS = "request.deepPaths";
/**
* distribution request type
*/
public static final String PROPERTY_REQUEST_TYPE = "request.type";
/**
* Creates a new wrapper around a given map.
*
* @param base wrapped object
* @param packageType type of package
*/
public DistributionPackageInfo(String packageType, Map base) {
super(base);
if (packageType == null) {
throw new IllegalArgumentException("package type cannot be null");
}
put(PROPERTY_PACKAGE_TYPE, packageType);
}
/**
* Creates a new wrapper around an empty map.
*
* @param packageType type of package
*/
public DistributionPackageInfo(String packageType) {
this(packageType, new HashMap());
}
@NotNull
public String getType() {
return get(PROPERTY_PACKAGE_TYPE, String.class);
}
/**
* get the paths covered by the package holding this info
*
* @return an array of paths
*/
@Nullable
public String[] getPaths() {
return get(PROPERTY_REQUEST_PATHS, String[].class);
}
/**
* get the request type associated to the package holding this info
*
* @return the request type
*/
@Nullable
public DistributionRequestType getRequestType() {
return get(PROPERTY_REQUEST_TYPE, DistributionRequestType.class);
}
@Override
public String toString() {
return "DistributionPackageInfo{" +
" request.type=" + get(PROPERTY_REQUEST_TYPE, DistributionRequestType.class) +
", request.paths=" + Arrays.toString(get(PROPERTY_REQUEST_PATHS, String[].class)) +
'}';
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy