com.landawn.abacus.type.SheetType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of abacus-common Show documentation
Show all versions of abacus-common Show documentation
A general programming library in Java/Android. It's easy to learn and simple to use with concise and powerful APIs.
/*
* Copyright (C) 2015 HaiYang Li
*
* 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.landawn.abacus.type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.landawn.abacus.parser.JSONDeserializationConfig;
import com.landawn.abacus.parser.JSONDeserializationConfig.JDC;
import com.landawn.abacus.util.ClassUtil;
import com.landawn.abacus.util.N;
import com.landawn.abacus.util.Sheet;
import com.landawn.abacus.util.WD;
// TODO: Auto-generated Javadoc
/**
*
* @author Haiyang Li
* @param
* @param
* @param
* @since 0.8
*/
@SuppressWarnings("java:S2160")
public class SheetType extends AbstractType> {
private static final String ROW_KEY_SET = "rowKeySet";
private static final String COLUMN_KEY_SET = "columnKeySet";
private static final String ROW_LIST = "rowList";
private final String declaringName;
private final Class> typeClass;
private final Type[] parameterTypes;
private final JSONDeserializationConfig jdc;
/**
*
*
* @param rowKeyTypeName
* @param columnKeyTypeName
* @param elementTypeName
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public SheetType(String rowKeyTypeName, String columnKeyTypeName, String elementTypeName) {
super(getTypeName(Sheet.class, rowKeyTypeName, columnKeyTypeName, elementTypeName, false));
this.declaringName = getTypeName(Sheet.class, rowKeyTypeName, columnKeyTypeName, elementTypeName, true);
this.typeClass = (Class) Sheet.class;
this.parameterTypes = new Type[] { TypeFactory.getType(rowKeyTypeName), TypeFactory.getType(columnKeyTypeName), TypeFactory.getType(elementTypeName) };
final Type rowKeyListType = TypeFactory.getType("List<" + rowKeyTypeName + ">");
final Type columnKeyListType = TypeFactory.getType("List<" + columnKeyTypeName + ">");
final Type rowListType = TypeFactory.getType("List>");
this.jdc = JDC.create().setPropType(ROW_KEY_SET, rowKeyListType).setPropType(COLUMN_KEY_SET, columnKeyListType).setPropType(ROW_LIST, rowListType);
}
/**
*
*
* @return
*/
@Override
public String declaringName() {
return declaringName;
}
/**
*
*
* @return
*/
@Override
public Class> clazz() {
return typeClass;
}
/**
* Gets the parameter types.
*
* @return
*/
@Override
public Type[] getParameterTypes() {
return parameterTypes;
}
/**
* Checks if is generic type.
*
* @return true, if is generic type
*/
@Override
public boolean isGenericType() {
return true;
}
/**
* Checks if is serializable.
*
* @return true, if is serializable
*/
@Override
public boolean isSerializable() {
return true;
}
/**
*
* @param x
* @return
*/
@Override
public String stringOf(Sheet x) {
if (x == null) {
return null;
}
final List> rowList = new ArrayList<>(x.rowLength());
for (R rowKey : x.rowKeySet()) {
rowList.add(x.getRow(rowKey));
}
final Map