Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8B03E200C24 for ; Thu, 9 Feb 2017 01:48:51 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 88239160B67; Thu, 9 Feb 2017 00:48:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D385B160B49 for ; Thu, 9 Feb 2017 01:48:50 +0100 (CET) Received: (qmail 81328 invoked by uid 500); 9 Feb 2017 00:48:45 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 81312 invoked by uid 99); 9 Feb 2017 00:48:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Feb 2017 00:48:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 97A1FC0C5C for ; Thu, 9 Feb 2017 00:48:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.998 X-Spam-Level: X-Spam-Status: No, score=-1.998 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id W4weqKstxPX0 for ; Thu, 9 Feb 2017 00:48:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id C90A15F24B for ; Thu, 9 Feb 2017 00:48:42 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id F01BAE0237 for ; Thu, 9 Feb 2017 00:48:41 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id AB7CC2528B for ; Thu, 9 Feb 2017 00:48:41 +0000 (UTC) Date: Thu, 9 Feb 2017 00:48:41 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COMMONSRDF-47) RDFSyntax should be interface, not enum MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 09 Feb 2017 00:48:51 -0000 [ https://issues.apache.org/jira/browse/COMMONSRDF-47?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15858790#comment-15858790 ] ASF GitHub Bot commented on COMMONSRDF-47: ------------------------------------------ Github user stain commented on a diff in the pull request: https://github.com/apache/commons-rdf/pull/27#discussion_r100208441 --- Diff: api/src/main/java/org/apache/commons/rdf/api/RDFSyntax.java --- @@ -178,17 +206,62 @@ private RDFSyntax(final String name, final String mediaType, final String fileEx * The fileExtension is compared in lower case, therefore it * might not be equal to the {@link RDFSyntax#fileExtension} of the returned * RDFSyntax. + *

+ * The list of syntaxes supported is at least those returned by + * {@link #w3cSyntaxes()}. * * @param fileExtension * The fileExtension to match, starting with . * @return If {@link Optional#isPresent()}, the {@link RDFSyntax} which has - * a matching {@link RDFSyntax#fileExtension}, otherwise + * a matching {@link RDFSyntax#fileExtension()}, otherwise * {@link Optional#empty()} indicating that no matching file * extension was found. */ public static Optional byFileExtension(final String fileExtension) { - final String ext = fileExtension.toLowerCase(Locale.ENGLISH); - return Arrays.stream(RDFSyntax.values()).filter(t -> t.fileExtension.equals(ext)).findAny(); + final String ext = fileExtension.toLowerCase(Locale.ROOT); + return w3cSyntaxes().stream().filter(t -> t.fileExtension().equals(ext)) + .findAny(); + } + + /** + * Return the RDFSyntax with the specified {@link #name()}. + *

+ * The list of syntaxes supported is at least those returned by --- End diff -- Changed to > This method support all syntaxes returned by {@link #w3cSyntaxes()} There is no good way from a static class method to allow user extension; at least without having a discovery mechanism (classpath sensitive) or mutable setters/registrations (initialization sensitive) - I would argue it is out of scope for this particular method to support that, as Commons RDF only target RDF 1.1. If you want we could change these lookup method to take a variable/optional list of `Iterable` as parameters? (The parser/writer methods would with this PR support `RDFSyntax` from "elsewhere" - e.g. we could return supported syntaxes from each `RDF` instance) > RDFSyntax should be interface, not enum > --------------------------------------- > > Key: COMMONSRDF-47 > URL: https://issues.apache.org/jira/browse/COMMONSRDF-47 > Project: Apache Commons RDF > Issue Type: Bug > Components: api > Affects Versions: 0.2.0 > Reporter: Stian Soiland-Reyes > Assignee: Stian Soiland-Reyes > > [~p_ansell] raises in [pull request 25|https://github.com/apache/incubator-commonsrdf/pull/25#discussion_r85231845] > {quote} > Using enum for RDFSyntax is a bad idea unless it overrides an interface and the interface is used in method signatures instead of the enum. There are many other RDFSyntaxes, and enum (without implementing an interface) is only suited to cases where the full set are known a priori. > {quote} -- This message was sent by Atlassian JIRA (v6.3.15#6346)