// Path: src/main/java/com/_4dconcept/springframework/data/marklogic/MarklogicUrlUtils.java
// public abstract class MarklogicUrlUtils {
// 
//     /**
//      * Private constructor to prevent instantiation.
//      */
//     private MarklogicUrlUtils() {}
// 
//     /**
//      * Obtains the uri name to use for the provided class
//      *
//      * @param entityClass The class to determine the preferred uri name for
//      * @return The preferred rul name
//      */
//     public static String getPreferredUrlPattern(Class<?> entityClass) {
//         String URL_PREFIX = "/content/";
//         String URL_SUFFIX = "/#{id}.xml";
//         return URL_PREFIX + entityClass.getSimpleName().toLowerCase() + URL_SUFFIX;
//     }
// }


import com._4dconcept.springframework.data.marklogic.MarklogicUrlUtils;
import org.springframework.data.mapping.MappingException;
import org.springframework.data.mapping.model.BasicPersistentEntity;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import java.util.Comparator;
/*
 * Copyright 2017 the original author or authors.
 *
 * 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._4dconcept.springframework.data.marklogic.core.mapping;



/**
 * Specialized value object to capture information of {@link MarklogicPersistentEntity}s.
 * It provide access to entity 'uri', 'defaultCollection'
 *
 * @author Stéphane Toussaint
 */
public class BasicMarklogicPersistentEntity<T> extends BasicPersistentEntity<T, MarklogicPersistentProperty> implements MarklogicPersistentEntity<T> {

    private final String uri;
    private @Nullable final String defaultCollection;
    private final boolean idInPropertyFragment;

    BasicMarklogicPersistentEntity(TypeInformation<T> information) {
        this(information, null);
    }

    private BasicMarklogicPersistentEntity(TypeInformation<T> information, @Nullable Comparator<MarklogicPersistentProperty> comparator) {
        super(information, comparator);

        Class<T> rawType = getTypeInformation().getType();
// Path: src/main/java/com/_4dconcept/springframework/data/marklogic/MarklogicUrlUtils.java
// public abstract class MarklogicUrlUtils {
// 
//     /**
//      * Private constructor to prevent instantiation.
//      */
//     private MarklogicUrlUtils() {}
// 
//     /**
//      * Obtains the uri name to use for the provided class
//      *
//      * @param entityClass The class to determine the preferred uri name for
//      * @return The preferred rul name
//      */
//     public static String getPreferredUrlPattern(Class<?> entityClass) {
//         String URL_PREFIX = "/content/";
//         String URL_SUFFIX = "/#{id}.xml";
//         return URL_PREFIX + entityClass.getSimpleName().toLowerCase() + URL_SUFFIX;
//     }
// }


// Path: src/main/java/com/_4dconcept/springframework/data/marklogic/core/mapping/BasicMarklogicPersistentEntity.java
import com._4dconcept.springframework.data.marklogic.MarklogicUrlUtils;
import org.springframework.data.mapping.MappingException;
import org.springframework.data.mapping.model.BasicPersistentEntity;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
import java.util.Comparator;

/*
 * Copyright 2017 the original author or authors.
 *
 * 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._4dconcept.springframework.data.marklogic.core.mapping;



/**
 * Specialized value object to capture information of {@link MarklogicPersistentEntity}s.
 * It provide access to entity 'uri', 'defaultCollection'
 *
 * @author Stéphane Toussaint
 */
public class BasicMarklogicPersistentEntity<T> extends BasicPersistentEntity<T, MarklogicPersistentProperty> implements MarklogicPersistentEntity<T> {

    private final String uri;
    private @Nullable final String defaultCollection;
    private final boolean idInPropertyFragment;

    BasicMarklogicPersistentEntity(TypeInformation<T> information) {
        this(information, null);
    }

    private BasicMarklogicPersistentEntity(TypeInformation<T> information, @Nullable Comparator<MarklogicPersistentProperty> comparator) {
        super(information, comparator);

        Class<T> rawType = getTypeInformation().getType();
        String fallback = MarklogicUrlUtils.getPreferredUrlPattern(rawType);