Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1497D10B79 for ; Sun, 1 Feb 2015 20:14:34 +0000 (UTC) Received: (qmail 85870 invoked by uid 500); 1 Feb 2015 20:14:34 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 85770 invoked by uid 500); 1 Feb 2015 20:14:34 -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 85758 invoked by uid 99); 1 Feb 2015 20:14:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Feb 2015 20:14:34 +0000 Date: Sun, 1 Feb 2015 20:14:34 +0000 (UTC) From: =?utf-8?Q?Michael_Gro=C3=9F_=28JIRA=29?= To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (IMAGING-159) There should be a Parameters class MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/IMAGING-159?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D143= 00717#comment-14300717 ]=20 Michael Gro=C3=9F edited comment on IMAGING-159 at 2/1/15 8:14 PM: -------------------------------------------------------------- updated my patch - waiting for review was (Author: mgmechanics): updated my patch > There should be a Parameters class > ---------------------------------- > > Key: IMAGING-159 > URL: https://issues.apache.org/jira/browse/IMAGING-159 > Project: Commons Imaging > Issue Type: Improvement > Components: imaging.* > Reporter: Benedikt Ritter > Fix For: Patch Needed > > > Currently options for image I/O are defined as Maps. The leads to the pro= blem that our code has to validate parameter types when they are used: > {code:java} > final Object value =3D params.get(PARAM_KEY_COMPRESSION); > if (value !=3D null) { > if (!(value instanceof Number)) { > throw new ImageWriteException( > "Invalid compression parameter, must be numeric: " > + value); > } > compression =3D ((Number) value).intValue(); > } > {code} > This can be simplified if we define a Parameters class that provides addi= tional methods like {{public int getInt(String key)}}. The implementation c= ould then look up the value from the map through an exception if it is null= or not a number. -- This message was sent by Atlassian JIRA (v6.3.4#6332)