-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,72 @@ public List<Node> get(Query query) | |
return new GetQuery(query).execute(this); | ||
} | ||
|
||
/** | ||
* Remove all child nodes found at the given query. | ||
* | ||
* @return the {@link List} of removed children. | ||
*/ | ||
public List<Node> remove(String name) | ||
{ | ||
if (name == null || name.trim().isEmpty()) | ||
{ | ||
throw new IllegalArgumentException("Path must not be null or empty"); | ||
} | ||
|
||
List<Node> found = get(name); | ||
for (Node child : found) | ||
{ | ||
children.remove(child); | ||
} | ||
return found; | ||
} | ||
|
||
/** | ||
* Remove all child nodes found at the given {@link Query}. | ||
* | ||
* @return the {@link List} of removed children. | ||
*/ | ||
public List<Node> remove(Query query) | ||
{ | ||
if (query == null) | ||
{ | ||
throw new IllegalArgumentException("Query must not be null"); | ||
} | ||
|
||
List<Node> found = get(query); | ||
for (Node child : found) | ||
{ | ||
children.remove(child); | ||
} | ||
return found; | ||
} | ||
|
||
/** | ||
* Remove a single child from this {@link Node} | ||
* | ||
* @return true if this node contained the given child | ||
*/ | ||
public boolean removeSingle(Node child) | ||
{ | ||
return children.remove(child); | ||
} | ||
|
||
/** | ||
* Remove a single child from this {@link Node} | ||
* | ||
* @return true if this node contained the given child | ||
* @throws IllegalArgumentException if multiple children with name exist. | ||
*/ | ||
public Node removeSingle(String name) | ||
{ | ||
Node node = getSingle(name); | ||
if (node != null) | ||
{ | ||
removeSingle(node); | ||
} | ||
return node; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lincolnthree
Author
Owner
|
||
} | ||
|
||
// -------------------------------------------------------------------------------------|| | ||
// Local data -------------------------------------------------------------------------|| | ||
// -------------------------------------------------------------------------------------|| | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.shrinkwrap.descriptor.api.spec.jpa.persistence; | ||
|
||
/** | ||
This comment has been minimized.
Sorry, something went wrong. |
||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
* | ||
*/ | ||
public interface Property | ||
{ | ||
|
||
Property name(String name); | ||
|
||
String getName(); | ||
|
||
Property value(Object value); | ||
|
||
Object getValue(); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.shrinkwrap.descriptor.impl.spec.jpa.persistence; | ||
|
||
import org.jboss.shrinkwrap.descriptor.api.Node; | ||
import org.jboss.shrinkwrap.descriptor.api.spec.jpa.persistence.Property; | ||
|
||
/** | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
* | ||
*/ | ||
public class PropertyImpl implements Property | ||
{ | ||
private final Node node; | ||
This comment has been minimized.
Sorry, something went wrong.
ALRubinger
|
||
|
||
public PropertyImpl(Node node, String name, Object value) | ||
{ | ||
this.node = node; | ||
node.attribute("name", name); | ||
node.attribute("value", value); | ||
} | ||
|
||
public PropertyImpl(Node node) | ||
{ | ||
this.node = node; | ||
} | ||
|
||
@Override | ||
public Property name(String name) | ||
{ | ||
node.attribute("name", name); | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getName() | ||
{ | ||
return node.attribute("name"); | ||
} | ||
|
||
@Override | ||
public Property value(Object value) | ||
{ | ||
node.attribute("value", value); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Object getValue() | ||
{ | ||
return node.attribute("value"); | ||
} | ||
|
||
} |
1 comment
on commit 968f697
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the line comments above. Also: I do love precondition checks for nulls, etc. :)
Returning true? Looks like it's returning the Node.