blob: 18b13bfb2ad571da33373a9cf9cf471cd7780611 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2013, 2018 CEA LIST and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* E.D.Willink(CEA LIST) - Initial API and implementation
*******************************************************************************/
package org.eclipse.ocl.examples.codegen.java.types;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.examples.codegen.generator.CodeGenerator;
import org.eclipse.ocl.examples.codegen.generator.TypeDescriptor;
import org.eclipse.ocl.pivot.ids.ElementId;
/**
* A SimpleValueDescriptor describes a type whose boxed and unboxed representations are the same. It has a pivot ElementId and a Java class.
* <p>
* Thus a StringValue is a TypeId.STRING and a java.lang.String.
*/
public class SimpleValueDescriptor extends AbstractValueDescriptor implements SimpleDescriptor
{
public SimpleValueDescriptor(@NonNull ElementId elementId, @NonNull Class<?> javaClass) {
super(elementId, javaClass);
}
@Override
public @NonNull EcoreDescriptor getEcoreDescriptor(@NonNull CodeGenerator codeGenerator, @Nullable Class<?> instanceClass) {
return this;
}
@Override
public final boolean isAssignableFrom(@NonNull TypeDescriptor typeDescriptor) {
if (!(typeDescriptor instanceof SimpleValueDescriptor)) {
return false;
}
return javaClass.isAssignableFrom(typeDescriptor.getJavaClass());
}
@Override
public @NonNull UnboxedDescriptor getUnboxedDescriptor(@NonNull CodeGenerator codeGenerator) {
return this;
}
}