{"id":6151,"date":"2023-11-01T17:04:52","date_gmt":"2023-11-02T00:04:52","guid":{"rendered":"https:\/\/ioflood.com\/blog\/?p=6151"},"modified":"2024-02-19T20:41:32","modified_gmt":"2024-02-20T03:41:32","slug":"java-predicate","status":"publish","type":"post","link":"https:\/\/ioflood.com\/blog\/java-predicate\/","title":{"rendered":"Understanding and Using Java Predicate: A Detailed Guide"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"alignright size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/ioflood.com\/blog\/wp-content\/uploads\/2023\/11\/java_predicate_filter_method_magnifying_glass-300x300.jpg\" alt=\"java_predicate_filter_method_magnifying_glass\" width=\"300\" height=\"300\" title=\"\"><\/figure>\n<\/div>\n<p>Are you finding it challenging to work with Java Predicates? You&#8217;re not alone. Many developers find themselves puzzled when it comes to using Java Predicates, but we&#8217;re here to help.<\/p>\n<p>Think of Java Predicates as your personal data detective &#8211; they can help you filter or evaluate data efficiently. Whether you&#8217;re dealing with collections, streams, or any other form of data, Java Predicates can be a powerful tool in your arsenal.<\/p>\n<p><strong>This guide will walk you through the process of understanding and using Java Predicates effectively<\/strong>, from the basics to more advanced techniques. We&#8217;ll cover everything from creating a Predicate, using the test() method, to more complex uses such as chaining Predicates using and(), or(), and negate().<\/p>\n<p>So, let&#8217;s dive in and start mastering Java Predicates!<\/p>\n<h2>TL;DR: What is a Java Predicate?<\/h2>\n<blockquote><p>\n  A Java Predicate is a functional interface that represents a boolean-valued function of one argument. It is instantiated by using the <code>Predicate<\/code> keyword followed by Constructor and variable name, for example: <code>Predicate&lt;String&gt; lengthIsEven<\/code>. It is commonly used to filter data.\n<\/p><\/blockquote>\n<p>Here&#8217;s a simple example:<\/p>\n<pre><code class=\"language-java line-numbers\">Predicate&lt;String&gt; lengthIsEven = s -&gt; s.length() % 2 == 0;\nboolean result = lengthIsEven.test(\"Hello\");\n\n\/\/ Output:\n\/\/ false\n<\/code><\/pre>\n<p>In this example, we&#8217;ve created a Predicate <code>lengthIsEven<\/code> that checks if the length of a string is even. We then test this Predicate with the string &#8220;Hello&#8221;, which has 5 characters, an odd number. Therefore, the result is <code>false<\/code>.<\/p>\n<blockquote><p>\n  This is just a basic way to use Java Predicates, but there&#8217;s so much more to explore. Continue reading for a more detailed understanding and advanced usage scenarios.\n<\/p><\/blockquote>\n<h2>Getting Started with Java Predicates<\/h2>\n<p>Java Predicates are a powerful tool for working with data, especially when you need to filter or evaluate it. Let&#8217;s break down how to use them, starting with the basics.<\/p>\n<h3>Creating a Java Predicate<\/h3>\n<p>A Java Predicate is a functional interface that can be defined using a lambda expression. Here&#8217;s an example of a simple Predicate that checks if a string has an even length:<\/p>\n<pre><code class=\"language-java line-numbers\">Predicate&lt;String&gt; lengthIsEven = s -&gt; s.length() % 2 == 0;\n<\/code><\/pre>\n<p>In this code, <code>lengthIsEven<\/code> is a Predicate that takes a string <code>s<\/code> and checks if its length is an even number. We use the lambda expression <code>s -&gt; s.length() % 2 == 0<\/code> to define this logic.<\/p>\n<h3>Using the test() Method<\/h3>\n<p>Once we have our Predicate, we can use it to evaluate data using the <code>test()<\/code> method. This method takes an input and applies the Predicate&#8217;s condition to it. Here&#8217;s how we can use our <code>lengthIsEven<\/code> Predicate to evaluate a string:<\/p>\n<pre><code class=\"language-java line-numbers\">boolean result = lengthIsEven.test(\"Hello\");\nSystem.out.println(result);\n\n\/\/ Output:\n\/\/ false\n<\/code><\/pre>\n<p>In this example, we&#8217;re testing the string &#8220;Hello&#8221; with our <code>lengthIsEven<\/code> Predicate. Since &#8220;Hello&#8221; has 5 characters (an odd number), the result is <code>false<\/code>.<\/p>\n<h3>Filtering Data with Java Predicates<\/h3>\n<p>Java Predicates are often used to filter data. For instance, you can use them to filter a collection of items that match a certain condition. Here&#8217;s an example of using a Predicate to filter a list of numbers:<\/p>\n<pre><code class=\"language-java line-numbers\">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5, 6);\nPredicate&lt;Integer&gt; isEven = n -&gt; n % 2 == 0;\n\nList&lt;Integer&gt; evenNumbers = numbers.stream()\n    .filter(isEven)\n    .collect(Collectors.toList());\n\nSystem.out.println(evenNumbers);\n\n\/\/ Output:\n\/\/ [2, 4, 6]\n<\/code><\/pre>\n<p>In this example, we&#8217;ve created a Predicate <code>isEven<\/code> that checks if a number is even. We then use this Predicate to filter our list of numbers and collect the even ones into a new list. The result is a list of the even numbers: <code>[2, 4, 6]<\/code>.<\/p>\n<h2>Chaining Java Predicates: and(), or(), negate()<\/h2>\n<p>As you become more comfortable with Java Predicates, you can start to use more advanced techniques. One such technique is chaining Predicates together using the <code>and()<\/code>, <code>or()<\/code>, and <code>negate()<\/code> methods. These methods allow you to combine multiple Predicates into a single, more complex Predicate.<\/p>\n<h3>Chaining with and()<\/h3>\n<p>The <code>and()<\/code> method allows you to chain two Predicates together. The resulting Predicate will return <code>true<\/code> if and only if both of the original Predicates return <code>true<\/code>. Here&#8217;s an example:<\/p>\n<pre><code class=\"language-java line-numbers\">Predicate&lt;String&gt; startsWithJ = s -&gt; s.startsWith(\"J\");\nPredicate&lt;String&gt; hasLengthOf5 = s -&gt; s.length() == 5;\n\nPredicate&lt;String&gt; startsWithJAndHasLengthOf5 = startsWithJ.and(hasLengthOf5);\n\nboolean result = startsWithJAndHasLengthOf5.test(\"Java\");\nSystem.out.println(result);\n\n\/\/ Output:\n\/\/ false\n<\/code><\/pre>\n<p>In this example, we first define two Predicates: <code>startsWithJ<\/code>, which checks if a string starts with &#8220;J&#8221;, and <code>hasLengthOf5<\/code>, which checks if a string has a length of 5. We then chain these two Predicates together using the <code>and()<\/code> method to create a new Predicate <code>startsWithJAndHasLengthOf5<\/code>. When we test this Predicate with the string &#8220;Java&#8221;, the result is <code>false<\/code> because while &#8220;Java&#8221; does start with &#8220;J&#8221;, it does not have a length of 5.<\/p>\n<h3>Chaining with or()<\/h3>\n<p>The <code>or()<\/code> method works similarly to <code>and()<\/code>, but it returns <code>true<\/code> if either of the original Predicates return <code>true<\/code>. Here&#8217;s how you might use it:<\/p>\n<pre><code class=\"language-java line-numbers\">Predicate&lt;String&gt; startsWithJOrHasLengthOf5 = startsWithJ.or(hasLengthOf5);\n\nboolean result = startsWithJOrHasLengthOf5.test(\"Java\");\nSystem.out.println(result);\n\n\/\/ Output:\n\/\/ true\n<\/code><\/pre>\n<p>In this example, we use the <code>or()<\/code> method to chain together our <code>startsWithJ<\/code> and <code>hasLengthOf5<\/code> Predicates. This time, when we test the resulting Predicate with the string &#8220;Java&#8221;, the result is <code>true<\/code> because &#8220;Java&#8221; does start with &#8220;J&#8221;, even though it does not have a length of 5.<\/p>\n<h3>Negating with negate()<\/h3>\n<p>Finally, the <code>negate()<\/code> method allows you to invert the result of a Predicate. Here&#8217;s an example:<\/p>\n<pre><code class=\"language-java line-numbers\">Predicate&lt;String&gt; notStartsWithJ = startsWithJ.negate();\n\nboolean result = notStartsWithJ.test(\"Java\");\nSystem.out.println(result);\n\n\/\/ Output:\n\/\/ false\n<\/code><\/pre>\n<p>In this example, we use the <code>negate()<\/code> method to create a new Predicate <code>notStartsWithJ<\/code> that returns <code>true<\/code> if a string does not start with &#8220;J&#8221;. When we test this Predicate with the string &#8220;Java&#8221;, the result is <code>false<\/code> because &#8220;Java&#8221; does start with &#8220;J&#8221;.<\/p>\n<h2>Exploring Alternative Data Filtering Techniques<\/h2>\n<p>Java offers multiple ways to filter data, not just with Predicates. Let&#8217;s explore some alternative approaches and compare them with using Java Predicates.<\/p>\n<h3>Filtering with Loops<\/h3>\n<p>A simple way to filter data is by using loops. Here&#8217;s an example of filtering a list of numbers to only include even numbers:<\/p>\n<pre><code class=\"language-java line-numbers\">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5, 6);\nList&lt;Integer&gt; evenNumbers = new ArrayList&lt;&gt;();\n\nfor (Integer number : numbers) {\n    if (number % 2 == 0) {\n        evenNumbers.add(number);\n    }\n}\n\nSystem.out.println(evenNumbers);\n\n\/\/ Output:\n\/\/ [2, 4, 6]\n<\/code><\/pre>\n<p>In this example, we&#8217;re looping through each number in our list and adding it to a new list if it&#8217;s even. This approach is straightforward, but it can become cumbersome and less readable as the complexity of the condition increases.<\/p>\n<h3>Filtering with Streams (Without Predicates)<\/h3>\n<p>Java Streams provide a more declarative way to filter data. Here&#8217;s how you can achieve the same result as above using a Stream:<\/p>\n<pre><code class=\"language-java line-numbers\">List&lt;Integer&gt; evenNumbers = numbers.stream()\n    .filter(n -&gt; n % 2 == 0)\n    .collect(Collectors.toList());\n\nSystem.out.println(evenNumbers);\n\n\/\/ Output:\n\/\/ [2, 4, 6]\n<\/code><\/pre>\n<p>In this example, we&#8217;re using the <code>filter()<\/code> method of the Stream API to filter our list of numbers. The argument to the <code>filter()<\/code> method is a lambda expression that defines our condition. This approach is more streamlined and easier to read than using a loop, especially for more complex conditions.<\/p>\n<h3>Comparing with Java Predicates<\/h3>\n<p>Both of the above methods can be used to filter data, but Java Predicates offer some advantages. Predicates are more flexible because they can be passed around as arguments and returned as results from methods. They can also be combined and reused in different contexts.<\/p>\n<p>For example, once we have a Predicate like <code>isEven<\/code>, we can use it in multiple places throughout our code. This is not possible with the conditions defined inside a loop or a Stream&#8217;s <code>filter()<\/code> method.<\/p>\n<p>In summary, while loops and Streams can be used to filter data in Java, Predicates offer a more flexible and reusable approach, especially for complex conditions and larger applications.<\/p>\n<h2>Troubleshooting Common Java Predicate Issues<\/h2>\n<p>As with any programming concept, there are potential pitfalls when using Java Predicates. Let&#8217;s discuss some common issues and how to avoid them.<\/p>\n<h3>NullPointerExceptions with Method References<\/h3>\n<p>One common issue is encountering a <code>NullPointerException<\/code> when using method references with Predicates. This usually happens when you&#8217;re dealing with a collection that contains <code>null<\/code> values. Here&#8217;s an example:<\/p>\n<pre><code class=\"language-java line-numbers\">List&lt;String&gt; strings = Arrays.asList(\"Hello\", null);\nPredicate&lt;String&gt; isShortWord = s -&gt; s.length() &lt; 4;\n\nstrings.stream()\n    .filter(isShortWord)\n    .forEach(System.out::println);\n\n\/\/ Output:\n\/\/ Exception in thread \"main\" java.lang.NullPointerException\n<\/code><\/pre>\n<p>In this example, we&#8217;re trying to filter a list of strings to only include short words. However, our list contains a <code>null<\/code> value, which causes a <code>NullPointerException<\/code> when we try to call the <code>length()<\/code> method on it.<\/p>\n<p>To avoid this issue, you can add an additional check to your Predicate to ignore <code>null<\/code> values:<\/p>\n<pre><code class=\"language-java line-numbers\">Predicate&lt;String&gt; isShortWord = s -&gt; s != null &amp;&amp; s.length() &lt; 4;\n\nstrings.stream()\n    .filter(isShortWord)\n    .forEach(System.out::println);\n\n\/\/ Output:\n\/\/ (no output)\n<\/code><\/pre>\n<p>In this updated example, our <code>isShortWord<\/code> Predicate first checks if a string is not <code>null<\/code> before trying to get its length. This prevents the <code>NullPointerException<\/code> and allows our code to run successfully.<\/p>\n<h3>Considerations When Chaining Predicates<\/h3>\n<p>When chaining Predicates using <code>and()<\/code>, <code>or()<\/code>, and <code>negate()<\/code>, keep in mind that the order of operations can affect the result. For example, the <code>and()<\/code> operation is not commutative when dealing with <code>null<\/code> values:<\/p>\n<pre><code class=\"language-java line-numbers\">Predicate&lt;String&gt; isNotNull = Objects::nonNull;\nPredicate&lt;String&gt; startsWithJ = s -&gt; s.startsWith(\"J\");\n\nPredicate&lt;String&gt; correctOrder = isNotNull.and(startsWithJ);\nPredicate&lt;String&gt; incorrectOrder = startsWithJ.and(isNotNull);\n\nSystem.out.println(correctOrder.test(null));  \/\/ false\nSystem.out.println(incorrectOrder.test(null));  \/\/ NullPointerException\n<\/code><\/pre>\n<p>In this example, <code>correctOrder<\/code> checks if a string is not <code>null<\/code> before checking if it starts with &#8220;J&#8221;. This prevents a <code>NullPointerException<\/code> from being thrown when we test it with <code>null<\/code>. On the other hand, <code>incorrectOrder<\/code> tries to check if <code>null<\/code> starts with &#8220;J&#8221; before checking if it&#8217;s not <code>null<\/code>, which throws a <code>NullPointerException<\/code>.<\/p>\n<p>In summary, when using Java Predicates, be mindful of potential <code>NullPointerExceptions<\/code> and the order of operations when chaining Predicates.<\/p>\n<h2>Delving into Java&#8217;s Functional Interfaces and Lambda Expressions<\/h2>\n<p>To fully grasp how Java Predicates work, we need to understand the concepts of functional interfaces and lambda expressions in Java, and how Predicates fit into these concepts.<\/p>\n<h3>Understanding Functional Interfaces<\/h3>\n<p>A functional interface in Java is an interface that contains exactly one abstract method. This concept is a fundamental part of Java&#8217;s support for lambda expressions and method references.<\/p>\n<p>Java Predicates are a perfect example of a functional interface. The <code>java.util.function.Predicate<\/code> interface contains one abstract method, <code>test()<\/code>, which takes an object and returns a boolean.<\/p>\n<pre><code class=\"language-java line-numbers\">@FunctionalInterface\npublic interface Predicate&lt;T&gt; {\n    boolean test(T t);\n}\n<\/code><\/pre>\n<p>In this code, <code>T<\/code> is the type of the object the Predicate evaluates, and <code>test()<\/code> is the method that performs the evaluation and returns the result.<\/p>\n<h3>Leveraging Lambda Expressions<\/h3>\n<p>Lambda expressions are a feature in Java that allow you to write shorter and more readable code when working with functional interfaces. They provide a concise syntax to create anonymous methods.<\/p>\n<p>When defining a Predicate, we often use lambda expressions. For example, here&#8217;s how we might define a Predicate that checks if a number is even:<\/p>\n<pre><code class=\"language-java line-numbers\">Predicate&lt;Integer&gt; isEven = n -&gt; n % 2 == 0;\n<\/code><\/pre>\n<p>In this code, <code>n -&gt; n % 2 == 0<\/code> is a lambda expression. It takes an integer <code>n<\/code> and returns <code>true<\/code> if <code>n<\/code> is even and <code>false<\/code> otherwise.<\/p>\n<p>Lambda expressions and functional interfaces are key to understanding and using Java Predicates effectively. They provide a flexible and powerful way to define conditions and evaluate data.<\/p>\n<h2>Java Predicates in Larger Applications<\/h2>\n<p>Java Predicates are not just useful for small tasks or simple programs. They play a vital role in larger applications, especially in data processing and filtering within business logic.<\/p>\n<p>Imagine you&#8217;re developing a large-scale application that deals with a significant amount of data. You need to filter this data based on various complex conditions. Java Predicates can make this task more manageable and your code more readable and maintainable.<\/p>\n<p>For instance, you could define a set of Predicates that each represent a different business rule. You can then combine these Predicates in various ways to implement complex business logic. This approach is not only efficient but also makes your code easier to understand and modify.<\/p>\n<h2>Exploring Related Concepts<\/h2>\n<p>Java Predicates are part of a larger ecosystem of functional programming features in Java. To get the most out of them, it&#8217;s worth exploring related concepts like Java Streams and other functional interfaces.<\/p>\n<p>Java Streams, for example, work hand-in-hand with Predicates to provide powerful and efficient data processing capabilities. Other functional interfaces, like <code>Function<\/code>, <code>Supplier<\/code>, and <code>Consumer<\/code>, can also be used in combination with Predicates to build complex data processing pipelines.<\/p>\n<h3>Further Resources for Java Predicate Proficiency<\/h3>\n<p>To deepen your understanding of Java Predicates and related concepts, here are some resources you might find helpful:<\/p>\n<ul>\n<li>IOFlood&#8217;s <a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ioflood.com\/blog\/java-interface\/\">Complete Java Interfaces Guide<\/a> &#8211; Understand the significance of interface segregation in Java.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ioflood.com\/blog\/java-iterable\/\">Java Iterable Interface: Guide<\/a> &#8211; Understand the Java Iterable interface for iterating over collections of elements.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ioflood.com\/blog\/jdbc-connection\/\">Establishing JDBC Connection in Java<\/a> &#8211; Understand connection pooling and best practices for managing JDBC connections.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.oracle.com\/webfolder\/technetwork\/tutorials\/obe\/java\/Lambda-QuickStart\/index.html\" target=\"_blank\" rel=\"noopener\">Java 8 Lambda Expressions &amp; Streams<\/a> &#8211; A quick start guide by Oracle on lambda expressions and streams in Java 8.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.baeldung.com\/java-8-functional-interfaces\" target=\"_blank\" rel=\"noopener\">Java 8 Functional Interfaces<\/a> &#8211; An in-depth article by Baeldung that covers various functional interfaces in Java 8.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/function\/Predicate.html\" target=\"_blank\" rel=\"noopener\">Java Predicate Documentation<\/a> &#8211; The official Java documentation for the <code>Predicate<\/code> interface.<\/p>\n<\/li>\n<\/ul>\n<h2>Wrapping Up: Mastering Java Predicates<\/h2>\n<p>In this comprehensive guide, we&#8217;ve dived deep into the world of Java Predicates, a powerful tool for data evaluation and filtering in Java.<\/p>\n<p>We kicked off with the basics, learning how to create and utilize Java Predicates, and then using the <code>test()<\/code> method to evaluate data. We provided practical examples along the way, showing how to filter data using Predicates.<\/p>\n<p>We then ventured into advanced territory, exploring how to chain Predicates using <code>and()<\/code>, <code>or()<\/code>, and <code>negate()<\/code>. We also discussed alternative approaches to data filtering in Java, comparing the use of loops and Streams with Predicates.<\/p>\n<p>We tackled common issues that you might encounter when using Java Predicates, such as <code>NullPointerExceptions<\/code> and order of operations when chaining Predicates, providing you with solutions and considerations for each issue.<\/p>\n<p>Here&#8217;s a quick comparison of the methods we&#8217;ve discussed:<\/p>\n<table>\n<thead>\n<tr>\n<th>Method<\/th>\n<th>Flexibility<\/th>\n<th>Reusability<\/th>\n<th>Complexity<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Java Predicates<\/td>\n<td>High<\/td>\n<td>High<\/td>\n<td>Moderate<\/td>\n<\/tr>\n<tr>\n<td>Loops<\/td>\n<td>Low<\/td>\n<td>Low<\/td>\n<td>Low<\/td>\n<\/tr>\n<tr>\n<td>Streams<\/td>\n<td>Moderate<\/td>\n<td>Moderate<\/td>\n<td>High<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Whether you&#8217;re just starting out with Java Predicates or you&#8217;re looking to level up your data evaluation and filtering skills, we hope this guide has given you a deeper understanding of Java Predicates and their capabilities.<\/p>\n<p>With their flexibility and reusability, Java Predicates are a powerful tool for data evaluation and filtering in Java. Now, you&#8217;re well equipped to enjoy these benefits. Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you finding it challenging to work with Java Predicates? You&#8217;re not alone. Many developers find themselves puzzled when it comes to using Java Predicates, but we&#8217;re here to help. Think of Java Predicates as your personal data detective &#8211; they can help you filter or evaluate data efficiently. Whether you&#8217;re dealing with collections, streams, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7287,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[154,121],"tags":[],"class_list":["post-6151","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-programming-coding","cat-154-id","cat-121-id","has_thumb"],"_links":{"self":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts\/6151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/comments?post=6151"}],"version-history":[{"count":10,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts\/6151\/revisions"}],"predecessor-version":[{"id":17552,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts\/6151\/revisions\/17552"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/media\/7287"}],"wp:attachment":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/media?parent=6151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/categories?post=6151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/tags?post=6151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}