All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ovirt.api.metamodel.concepts.Expression Maven / Gradle / Ivy

There is a newer version: 1.3.10
Show newest version
/*
Copyright (c) 2015 Red Hat, Inc.

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 org.ovirt.api.metamodel.concepts;

import java.io.Serializable;

import org.ovirt.api.metamodel.concepts.Type;

/**
 * Base class for the different types of expressions.
 */
public abstract class Expression implements Serializable {
    // The type of the values generated by the expression:
    private Type type;

    /**
     * Returns the type of the values of the expression.
     */
    public Type getType() {
        return type;
    }

    /**
     * Sets the type of the values of the expression.
     */
    public void setType(Type newType) {
        type = newType;
    }

    /**
     * The boolean flag indicates if the result should be protected using parenthesis. The implementation may decide
     * to ignore this. For example, a literal expression like {@code 23} can ignore it, as it will never need
     * parenthesis to protect it.
     */
    public abstract String toString(boolean protect);

    /**
     * Generates the string representation of the string, assuming that it is going to be used in a place that doesn't
     * require parenthesis. If this isn't the case consider using the {@link #toString(boolean)} method, passing the
     * {@code true} as the value of the {@code protect} parameter.
     */
    @Override
    public String toString() {
        return toString(false);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy