package org.jeecg.modules.adweb.dmp.dto.google;

import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.io.Serializable;
import java.util.List;

/**
 * @author wfansh
 */
@Data
@SuperBuilder
@NoArgsConstructor
public abstract class ResourceDTO implements Serializable {

    protected static final char RESOURCE_NAME_SPLITTER = '/';

    private String id;

    private String resourceName;

    private String displayName;

    /** Parses ID from the resource name. */
    public static String parseId(String resourceName) {
        List<String> parts = Splitter.on(RESOURCE_NAME_SPLITTER).splitToList(resourceName);
        return parts.isEmpty() ? null : Iterables.getLast(parts);
    }
}
