Author: oheger
Date: Mon May 19 19:55:23 2014
New Revision: 1596018
URL: http://svn.apache.org/r1596018
Log:
Added a new ConfigurationBuilderEvent class.
This is the new base class for all events related to configuration builders.
Added:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ConfigurationBuilderEvent.java
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicConfigurationBuilderEvents.java
Added:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ConfigurationBuilderEvent.java
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ConfigurationBuilderEvent.java?rev=1596018&view=auto
==============================================================================
---
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ConfigurationBuilderEvent.java
(added)
+++
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ConfigurationBuilderEvent.java
Mon May 19 19:55:23 2014
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.commons.configuration.builder;
+
+import org.apache.commons.configuration.event.Event;
+import org.apache.commons.configuration.event.EventType;
+
+/**
+ * <p>
+ * A base event class for events generated by a {@link ConfigurationBuilder}.
+ * </p>
+ * <p>
+ * Configuration builders can trigger a number of different events. All these
+ * events are derived from this class. This event base class does not define
any
+ * additional properties. However, it defines that the event source must be a
+ * {@code ConfigurationBuilder}.
+ * </p>
+ *
+ * @version $Id$
+ * @since 2.0
+ */
+public class ConfigurationBuilderEvent extends Event
+{
+ /** The common super type for all events related to configuration
builders. */
+ public static final EventType<ConfigurationBuilderEvent> ANY =
+ new EventType<ConfigurationBuilderEvent>(Event.ANY, "BUILDER");
+
+ /**
+ * Creates a new instance of {@code ConfigurationBuilderEvent} and sets
+ * basic properties.
+ *
+ * @param source the {@code ConfigurationBuilder} object which triggered
+ * this event (must not be <b>null</b>)
+ * @param evType the type of this event (must not be <b>null</b>)
+ * @throws IllegalArgumentException if a required parameter is null
+ */
+ public ConfigurationBuilderEvent(ConfigurationBuilder<?> source,
+ EventType<? extends ConfigurationBuilderEvent> evType)
+ {
+ super(source, evType);
+ }
+
+ /**
+ * Returns the source of this event as a {@code ConfigurationBuilder}.
+ *
+ * @return the {@code ConfigurationBuilder} which generated this event
+ */
+ @Override
+ public ConfigurationBuilder<?> getSource()
+ {
+ return (ConfigurationBuilder<?>) super.getSource();
+ }
+}
Added:
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicConfigurationBuilderEvents.java
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicConfigurationBuilderEvents.java?rev=1596018&view=auto
==============================================================================
---
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicConfigurationBuilderEvents.java
(added)
+++
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicConfigurationBuilderEvents.java
Mon May 19 19:55:23 2014
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.commons.configuration.builder;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.commons.configuration.event.Event;
+import org.apache.commons.configuration.event.EventType;
+import org.junit.Test;
+
+/**
+ * A test class for {@code BasicConfigurationBuilder} with tests related to
+ * events fired by the builder.
+ *
+ * @version $Id$
+ */
+public class TestBasicConfigurationBuilderEvents
+{
+ /**
+ * Tests whether the base type for builder events is correctly configured.
+ */
+ @Test
+ public void testBuilderEventType()
+ {
+ EventType<ConfigurationBuilderEvent> builderEventType =
+ ConfigurationBuilderEvent.ANY;
+ assertEquals("Wrong super type", Event.ANY,
+ builderEventType.getSuperType());
+ }
+}