com.algoTrader.CriteriaSearchProperties.java Source code

Java tutorial

Introduction

Here is the source code for com.algoTrader.CriteriaSearchProperties.java

Source

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by: hibernate/HibernateSearchProperties.vsl in andromda-spring-cartridge.
//
package com.algoTrader;

import com.algoTrader.entity.PositionImpl;
import com.algoTrader.entity.StrategyImpl;
import com.algoTrader.entity.TransactionImpl;
import com.algoTrader.entity.WatchListItemImpl;
import com.algoTrader.entity.marketData.AskImpl;
import com.algoTrader.entity.marketData.BarImpl;
import com.algoTrader.entity.marketData.BidImpl;
import com.algoTrader.entity.marketData.GenericMarketDataEventImpl;
import com.algoTrader.entity.marketData.MarketDataEventDefinitionImpl;
import com.algoTrader.entity.marketData.MarketDataEventImpl;
import com.algoTrader.entity.marketData.NumericMarketDataEventImpl;
import com.algoTrader.entity.marketData.PriceEventImpl;
import com.algoTrader.entity.marketData.QuoteImpl;
import com.algoTrader.entity.marketData.TextualMarketDataEventImpl;
import com.algoTrader.entity.marketData.TickImpl;
import com.algoTrader.entity.marketData.TradeImpl;
import com.algoTrader.entity.security.EquityIndexImpl;
import com.algoTrader.entity.security.ForexImpl;
import com.algoTrader.entity.security.FutureImpl;
import com.algoTrader.entity.security.IntrestRateImpl;
import com.algoTrader.entity.security.SecurityFamilyImpl;
import com.algoTrader.entity.security.SecurityImpl;
import com.algoTrader.entity.security.StockImpl;
import com.algoTrader.entity.security.StockOptionImpl;
import com.algoTrader.entity.trade.FillImpl;
import com.algoTrader.entity.trade.LimitOrderImpl;
import com.algoTrader.entity.trade.MarketOrderImpl;
import com.algoTrader.entity.trade.OrderImpl;
import com.algoTrader.entity.trade.OrderStatusImpl;
import com.algoTrader.entity.trade.SteppingLimitOrderImpl;
import com.algoTrader.entity.trade.StopLimitOrderImpl;
import com.algoTrader.entity.trade.StopOrderImpl;
import com.algoTrader.entity.trade.TrailingStopOrderImpl;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;

/**
 * Stores the embedded values and associations of all entities in the system by type.
 * Is used to determine the appropriate parameter name when an embedded value's property
 * is referenced as the attribute to search by (as opposed to an association).
 *
 * @author Chad Brandon
 */
@SuppressWarnings({ "unchecked" })
public class CriteriaSearchProperties {
    private static final Map embeddedValuesByType = new HashMap();
    private static final Map embeddedValueNamesByType = new HashMap();
    private static final Map navigableAssociationEndsByType = new HashMap();

    static {
        initializeWatchListItem1();
        initializeFill2();
        initializeStopOrder3();
        initializeStopLimitOrder4();
        initializeOrder5();
        initializeMarketOrder6();
        initializeLimitOrder7();
        initializeTrailingStopOrder8();
        initializeOrderStatus9();
        initializeSteppingLimitOrder10();
        initializeBar11();
        initializeTrade12();
        initializeTick13();
        initializeQuote14();
        initializePriceEvent15();
        initializeBid16();
        initializeAsk17();
        initializeMarketDataEvent18();
        initializeMarketDataEventDefinition19();
        initializeGenericMarketDataEvent20();
        initializeNumericMarketDataEvent21();
        initializeTextualMarketDataEvent22();
        initializeTransaction23();
        initializePosition24();
        initializeStrategy25();
        initializeSecurityFamily26();
        initializeSecurity27();
        initializeIntrestRate28();
        initializeForex29();
        initializeFuture30();
        initializeStockOption31();
        initializeEquityIndex32();
        initializeStock33();
    }

    private static final void initializeWatchListItem1() {
        embeddedValueNamesByType.put(WatchListItemImpl.class, null);
        embeddedValuesByType.put(WatchListItemImpl.class, null);
        navigableAssociationEndsByType.put(WatchListItemImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("strategy", StrategyImpl.class) }));
    }

    private static final void initializeFill2() {
        embeddedValueNamesByType.put(FillImpl.class, null);
        embeddedValuesByType.put(FillImpl.class, null);
        navigableAssociationEndsByType.put(FillImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("transaction", TransactionImpl.class),
                        new PropertyType("parentOrder", OrderImpl.class) }));
    }

    private static final void initializeStopOrder3() {
        embeddedValueNamesByType.put(StopOrderImpl.class, null);
        embeddedValuesByType.put(StopOrderImpl.class, null);
        navigableAssociationEndsByType.put(StopOrderImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("strategy", StrategyImpl.class),
                        new PropertyType("parentOrder", OrderImpl.class),
                        new PropertyType("childOrders", OrderImpl.class) }));
    }

    private static final void initializeStopLimitOrder4() {
        embeddedValueNamesByType.put(StopLimitOrderImpl.class, null);
        embeddedValuesByType.put(StopLimitOrderImpl.class, null);
        navigableAssociationEndsByType.put(StopLimitOrderImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("strategy", StrategyImpl.class),
                        new PropertyType("parentOrder", OrderImpl.class),
                        new PropertyType("childOrders", OrderImpl.class) }));
    }

    private static final void initializeOrder5() {
        embeddedValueNamesByType.put(OrderImpl.class, null);
        embeddedValuesByType.put(OrderImpl.class, null);
        navigableAssociationEndsByType.put(OrderImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("strategy", StrategyImpl.class),
                        new PropertyType("parentOrder", OrderImpl.class),
                        new PropertyType("childOrders", OrderImpl.class) }));
    }

    private static final void initializeMarketOrder6() {
        embeddedValueNamesByType.put(MarketOrderImpl.class, null);
        embeddedValuesByType.put(MarketOrderImpl.class, null);
        navigableAssociationEndsByType.put(MarketOrderImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("strategy", StrategyImpl.class),
                        new PropertyType("parentOrder", OrderImpl.class),
                        new PropertyType("childOrders", OrderImpl.class) }));
    }

    private static final void initializeLimitOrder7() {
        embeddedValueNamesByType.put(LimitOrderImpl.class, null);
        embeddedValuesByType.put(LimitOrderImpl.class, null);
        navigableAssociationEndsByType.put(LimitOrderImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("strategy", StrategyImpl.class),
                        new PropertyType("parentOrder", OrderImpl.class),
                        new PropertyType("childOrders", OrderImpl.class) }));
    }

    private static final void initializeTrailingStopOrder8() {
        embeddedValueNamesByType.put(TrailingStopOrderImpl.class, null);
        embeddedValuesByType.put(TrailingStopOrderImpl.class, null);
        navigableAssociationEndsByType.put(TrailingStopOrderImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("strategy", StrategyImpl.class),
                        new PropertyType("parentOrder", OrderImpl.class),
                        new PropertyType("childOrders", OrderImpl.class) }));
    }

    private static final void initializeOrderStatus9() {
        embeddedValueNamesByType.put(OrderStatusImpl.class, null);
        embeddedValuesByType.put(OrderStatusImpl.class, null);
        navigableAssociationEndsByType.put(OrderStatusImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("parentOrder", OrderImpl.class) }));
    }

    private static final void initializeSteppingLimitOrder10() {
        embeddedValueNamesByType.put(SteppingLimitOrderImpl.class, null);
        embeddedValuesByType.put(SteppingLimitOrderImpl.class, null);
        navigableAssociationEndsByType.put(SteppingLimitOrderImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("strategy", StrategyImpl.class),
                        new PropertyType("parentOrder", OrderImpl.class),
                        new PropertyType("childOrders", OrderImpl.class) }));
    }

    private static final void initializeBar11() {
        embeddedValueNamesByType.put(BarImpl.class, null);
        embeddedValuesByType.put(BarImpl.class, null);
        navigableAssociationEndsByType.put(BarImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeTrade12() {
        embeddedValueNamesByType.put(TradeImpl.class, null);
        embeddedValuesByType.put(TradeImpl.class, null);
        navigableAssociationEndsByType.put(TradeImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeTick13() {
        embeddedValueNamesByType.put(TickImpl.class, null);
        embeddedValuesByType.put(TickImpl.class, null);
        navigableAssociationEndsByType.put(TickImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeQuote14() {
        embeddedValueNamesByType.put(QuoteImpl.class, null);
        embeddedValuesByType.put(QuoteImpl.class, null);
        navigableAssociationEndsByType.put(QuoteImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializePriceEvent15() {
        embeddedValueNamesByType.put(PriceEventImpl.class, null);
        embeddedValuesByType.put(PriceEventImpl.class, null);
        navigableAssociationEndsByType.put(PriceEventImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeBid16() {
        embeddedValueNamesByType.put(BidImpl.class, null);
        embeddedValuesByType.put(BidImpl.class, null);
        navigableAssociationEndsByType.put(BidImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeAsk17() {
        embeddedValueNamesByType.put(AskImpl.class, null);
        embeddedValuesByType.put(AskImpl.class, null);
        navigableAssociationEndsByType.put(AskImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeMarketDataEvent18() {
        embeddedValueNamesByType.put(MarketDataEventImpl.class, null);
        embeddedValuesByType.put(MarketDataEventImpl.class, null);
        navigableAssociationEndsByType.put(MarketDataEventImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeMarketDataEventDefinition19() {
        embeddedValueNamesByType.put(MarketDataEventDefinitionImpl.class, null);
        embeddedValuesByType.put(MarketDataEventDefinitionImpl.class, null);
        navigableAssociationEndsByType.put(MarketDataEventDefinitionImpl.class, null);
    }

    private static final void initializeGenericMarketDataEvent20() {
        embeddedValueNamesByType.put(GenericMarketDataEventImpl.class, null);
        embeddedValuesByType.put(GenericMarketDataEventImpl.class, null);
        navigableAssociationEndsByType.put(GenericMarketDataEventImpl.class,
                Arrays.asList(
                        new PropertyType[] { new PropertyType("definition", MarketDataEventDefinitionImpl.class),
                                new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeNumericMarketDataEvent21() {
        embeddedValueNamesByType.put(NumericMarketDataEventImpl.class, null);
        embeddedValuesByType.put(NumericMarketDataEventImpl.class, null);
        navigableAssociationEndsByType.put(NumericMarketDataEventImpl.class,
                Arrays.asList(
                        new PropertyType[] { new PropertyType("definition", MarketDataEventDefinitionImpl.class),
                                new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeTextualMarketDataEvent22() {
        embeddedValueNamesByType.put(TextualMarketDataEventImpl.class, null);
        embeddedValuesByType.put(TextualMarketDataEventImpl.class, null);
        navigableAssociationEndsByType.put(TextualMarketDataEventImpl.class,
                Arrays.asList(
                        new PropertyType[] { new PropertyType("definition", MarketDataEventDefinitionImpl.class),
                                new PropertyType("security", SecurityImpl.class) }));
    }

    private static final void initializeTransaction23() {
        embeddedValueNamesByType.put(TransactionImpl.class, null);
        embeddedValuesByType.put(TransactionImpl.class, null);
        navigableAssociationEndsByType.put(TransactionImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("position", PositionImpl.class),
                        new PropertyType("strategy", StrategyImpl.class) }));
    }

    private static final void initializePosition24() {
        embeddedValueNamesByType.put(PositionImpl.class, null);
        embeddedValuesByType.put(PositionImpl.class, null);
        navigableAssociationEndsByType.put(PositionImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("security", SecurityImpl.class),
                        new PropertyType("strategy", StrategyImpl.class),
                        new PropertyType("transactions", TransactionImpl.class) }));
    }

    private static final void initializeStrategy25() {
        embeddedValueNamesByType.put(StrategyImpl.class, null);
        embeddedValuesByType.put(StrategyImpl.class, null);
        navigableAssociationEndsByType.put(StrategyImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("watchListItems", WatchListItemImpl.class),
                        new PropertyType("positions", PositionImpl.class),
                        new PropertyType("transactions", TransactionImpl.class) }));
    }

    private static final void initializeSecurityFamily26() {
        embeddedValueNamesByType.put(SecurityFamilyImpl.class, null);
        embeddedValuesByType.put(SecurityFamilyImpl.class, null);
        navigableAssociationEndsByType.put(SecurityFamilyImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("underlaying", SecurityImpl.class),
                        new PropertyType("securities", SecurityImpl.class) }));
    }

    private static final void initializeSecurity27() {
        embeddedValueNamesByType.put(SecurityImpl.class, null);
        embeddedValuesByType.put(SecurityImpl.class, null);
        navigableAssociationEndsByType.put(SecurityImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("watchListItems", WatchListItemImpl.class),
                        new PropertyType("positions", PositionImpl.class),
                        new PropertyType("underlaying", SecurityImpl.class),
                        new PropertyType("securityFamilies", SecurityFamilyImpl.class),
                        new PropertyType("securityFamily", SecurityFamilyImpl.class) }));
    }

    private static final void initializeIntrestRate28() {
        embeddedValueNamesByType.put(IntrestRateImpl.class, null);
        embeddedValuesByType.put(IntrestRateImpl.class, null);
        navigableAssociationEndsByType.put(IntrestRateImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("watchListItems", WatchListItemImpl.class),
                        new PropertyType("positions", PositionImpl.class),
                        new PropertyType("underlaying", SecurityImpl.class),
                        new PropertyType("securityFamilies", SecurityFamilyImpl.class),
                        new PropertyType("securityFamily", SecurityFamilyImpl.class) }));
    }

    private static final void initializeForex29() {
        embeddedValueNamesByType.put(ForexImpl.class, null);
        embeddedValuesByType.put(ForexImpl.class, null);
        navigableAssociationEndsByType.put(ForexImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("watchListItems", WatchListItemImpl.class),
                        new PropertyType("positions", PositionImpl.class),
                        new PropertyType("underlaying", SecurityImpl.class),
                        new PropertyType("securityFamilies", SecurityFamilyImpl.class),
                        new PropertyType("securityFamily", SecurityFamilyImpl.class) }));
    }

    private static final void initializeFuture30() {
        embeddedValueNamesByType.put(FutureImpl.class, null);
        embeddedValuesByType.put(FutureImpl.class, null);
        navigableAssociationEndsByType.put(FutureImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("watchListItems", WatchListItemImpl.class),
                        new PropertyType("positions", PositionImpl.class),
                        new PropertyType("underlaying", SecurityImpl.class),
                        new PropertyType("securityFamilies", SecurityFamilyImpl.class),
                        new PropertyType("securityFamily", SecurityFamilyImpl.class) }));
    }

    private static final void initializeStockOption31() {
        embeddedValueNamesByType.put(StockOptionImpl.class, null);
        embeddedValuesByType.put(StockOptionImpl.class, null);
        navigableAssociationEndsByType.put(StockOptionImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("watchListItems", WatchListItemImpl.class),
                        new PropertyType("positions", PositionImpl.class),
                        new PropertyType("underlaying", SecurityImpl.class),
                        new PropertyType("securityFamilies", SecurityFamilyImpl.class),
                        new PropertyType("securityFamily", SecurityFamilyImpl.class) }));
    }

    private static final void initializeEquityIndex32() {
        embeddedValueNamesByType.put(EquityIndexImpl.class, null);
        embeddedValuesByType.put(EquityIndexImpl.class, null);
        navigableAssociationEndsByType.put(EquityIndexImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("watchListItems", WatchListItemImpl.class),
                        new PropertyType("positions", PositionImpl.class),
                        new PropertyType("underlaying", SecurityImpl.class),
                        new PropertyType("securityFamilies", SecurityFamilyImpl.class),
                        new PropertyType("securityFamily", SecurityFamilyImpl.class) }));
    }

    private static final void initializeStock33() {
        embeddedValueNamesByType.put(StockImpl.class, null);
        embeddedValuesByType.put(StockImpl.class, null);
        navigableAssociationEndsByType.put(StockImpl.class,
                Arrays.asList(new PropertyType[] { new PropertyType("watchListItems", WatchListItemImpl.class),
                        new PropertyType("positions", PositionImpl.class),
                        new PropertyType("underlaying", SecurityImpl.class),
                        new PropertyType("securityFamilies", SecurityFamilyImpl.class),
                        new PropertyType("securityFamily", SecurityFamilyImpl.class) }));
    }

    /**
     * Attempts to get the embedded value list for the given type (or returns null
     * if one doesn't exist).
     *
     * @param type the type of which to retrieve the value.
     * @return the collection of embedded value names.
     */
    public static Collection getEmbeddedValues(final Class type) {
        return (Collection) embeddedValueNamesByType.get(type);
    }

    /**
     * Gets the type of the navigable association end given the <code>ownerType</code>
     * and <code>name</code>
     *
     * @param ownerType the owner of the association.
     * @param name the name of the association end to find.
     * @return the type of the association end.
     */
    public static Class getNavigableAssociationEndType(final Class ownerType, final String name) {
        return getPropertyType(navigableAssociationEndsByType, ownerType, name);
    }

    /**
     * Gets the type of the embedded value given the <code>ownerType</code>
     * and <code>name</code>
     *
     * @param ownerType the owner of the association.
     * @param name the name of the association end to find.
     * @return the type of the association end.
     */
    public static Class getEmbeddedValueType(final Class ownerType, final String name) {
        return getPropertyType(embeddedValuesByType, ownerType, name);
    }

    /**
     * Gets the type of the embedded value given the <code>ownerType</code>
     * and <code>name</code>
     *
     * @param properties Map contains the Collection of properties given the ownerType Class
     * @param ownerType the owner of the association.
     * @param name the name of the association end to find.
     * @return the type of the association end.
     */
    public static Class getPropertyType(final Map properties, final Class ownerType, final String name) {
        final Collection ends = (Collection) properties.get(ownerType);
        final PropertyType type = (PropertyType) CollectionUtils.find(ends, new Predicate() {
            public boolean evaluate(final Object object) {
                return ((PropertyType) object).name.equals(name);
            }
        });
        return type != null ? type.type : null;
    }

    /**
     * Gets the type of the property given the <code>ownerType</code>
     * and <code>name</code>
     *
     * @param ownerType the owner of the association.
     * @param name the name of the association end to find.
     * @return the type of the association end.
     */
    public static Class getPropertyType(final Class ownerType, final String name) {
        Class type = getNavigableAssociationEndType(ownerType, name);
        if (type == null) {
            type = getEmbeddedValueType(ownerType, name);
        }
        return type;
    }

    /**
     * A private class storing the name and type.
     */
    protected static final class PropertyType {
        /**
         * @param nameIn
         * @param typeIn
         */
        protected PropertyType(final String nameIn, final Class typeIn) {
            this.name = nameIn;
            this.type = typeIn;
        }

        /** PropertyType name */
        protected String name;
        /** PropertyType type Class */
        protected Class type;
    }
}