Java tutorial
/** * Copyright 2015 Appvengers * * 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 aeon.compiler.context; import com.google.common.collect.ImmutableList; import org.jetbrains.annotations.NotNull; import static com.google.common.base.Preconditions.checkNotNull; /** * @author Sven Jacobs */ public class SqliteContext extends AbstractContext<SqliteFieldContext> { private final SqliteEntityName mTableName; /** * Creates a {@link aeon.compiler.context.SqliteContext} from an instance of {@link aeon.compiler.context.Context}. * * @param context Source Context for building SqliteContext * @return SqliteContext build from Context */ @NotNull public static SqliteContext of(@NotNull final Context context) { checkNotNull(context); final SqliteEntityName targetClassName = SqliteEntityName .fromName(context.getTargetClassName().simpleName()); final ImmutableList.Builder<SqliteField> builder = ImmutableList.builder(); for (final Field field : context.getFieldContext().getFields()) { builder.add(SqliteField.of(field)); } return new SqliteContext(targetClassName, builder.build()); } private SqliteContext(@NotNull final SqliteEntityName tableName, @NotNull final ImmutableList<SqliteField> fields) { super(new SqliteFieldContext(fields)); mTableName = checkNotNull(tableName); } @NotNull public SqliteEntityName getTableName() { return mTableName; } }