com.exadel.aem.toolkit.plugin.sources.ComponentSourceImpl Maven / Gradle / Ivy
/*
* Licensed 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 com.exadel.aem.toolkit.plugin.sources;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Streams;
import com.exadel.aem.toolkit.api.annotations.main.AemComponent;
import com.exadel.aem.toolkit.api.annotations.main.Dialog;
import com.exadel.aem.toolkit.api.annotations.main.WriteMode;
import com.exadel.aem.toolkit.api.handlers.Source;
import com.exadel.aem.toolkit.core.CoreConstants;
import com.exadel.aem.toolkit.plugin.maven.PluginRuntime;
/**
* Implements {@link Source} to expose the metadata that is specific for the Java class representing an AEM component
*/
class ComponentSourceImpl extends ClassSourceImpl implements ComponentSource {
private static final String ROOT_DIRECTORY = "jcr_root";
private final String componentPath;
/**
* Initializes a class instance storing a reference to the {@code Class} that serves as the metadata source
* @param value The metadata source
*/
ComponentSourceImpl(Class> value) {
super(value);
componentPath = preparePath();
}
/**
* {@inheritDoc}
*/
@Override
public String getPath() {
return componentPath;
}
/**
* {@inheritDoc}
*/
@Override
public WriteMode getWriteMode() {
return tryAdaptTo(AemComponent.class)
.map(AemComponent::writeMode)
.orElse(null);
}
/**
* {@inheritDoc}
*/
@Override
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy