summaryrefslogtreecommitdiff
path: root/ant/ant14/com/vladium/emma/ant/NestedTask.java
blob: cd2c0ad9525ee9d3a017fb67808bd658f17b711e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
 * 
 * This program and the accompanying materials are made available under
 * the terms of the Common Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/cpl-v10.html
 * 
 * $Id: NestedTask.java,v 1.1.1.1.2.1 2004/07/08 10:52:10 vlad_r Exp $
 */
package com.vladium.emma.ant;

import com.vladium.util.IProperties;

// ----------------------------------------------------------------------------
/**
 * @author Vlad Roubtsov, (C) 2003
 */
public
abstract class NestedTask extends SuppressableTask
{
    // public: ................................................................
    
    // protected: .............................................................
    
    
    protected NestedTask (final SuppressableTask parent)
    {
        if (parent == null)
            throw new IllegalArgumentException ("null input: parent");
        
        m_parent = parent;
    }

    /**
     * Overrides {@link SuppressableTask#getTaskSettings()} to mix in parent
     * task settings as the base settings. 
     */
    protected final IProperties getTaskSettings ()
    {
        final IProperties parentSettings = m_parent != null
            ? m_parent.getTaskSettings ()
            : null;
        
        final IProperties taskOverrides = super.getTaskSettings ();
        
        // task settings are always more specific than parent settings, but attention
        // needs to be paid to horizontal inheritance:
        
        if (parentSettings == null)
            return taskOverrides;
        else
        {
            final IProperties settings = IProperties.Factory.combine (taskOverrides, parentSettings);
        
            return settings;
        }
    }

    
    protected final SuppressableTask m_parent;

    // package: ...............................................................
    
    // private: ...............................................................
    
} // end of class
// ----------------------------------------------------------------------------