Code review comment: Not needed: Since PROP_REQUEST was private, there is no chance that anybody is already using this property name - it is not part of the API of properties.

Code before review:
public void set(CompoundName key, Object value, Map<String,String> context) {
try {
if (key.size()==2 && key.first().equals(Model.MODEL)) {
Model model = query.getModel();
if (key.last().equals(Model.QUERY_STRING))
model.setQueryString(asString(value, ""));
else if (key.last().equals(Model.TYPE))
model.setType(asString(value, "ANY"));
else if (key.last().equals(Model.FILTER))
model.setFilter(asString(value, ""));
else if (key.last().equals(Model.DEFAULT_INDEX))
model.setDefaultIndex(asString(value, ""));
else if (key.last().equals(Model.LANGUAGE))
model.setLanguage(asString(value, ""));
else if (key.last().equals(Model.ENCODING))
model.setEncoding(asString(value,""));
else if (key.last().equals(Model.SEARCH_PATH))
model.setSearchPath(asString(value,""));
else if (key.last().equals(Model.SOURCES))
model.setSources(asString(value,""));
else if (key.last().equals(Model.RESTRICT))
model.setRestrict(asString(value,""));
else
throwIllegalParameter(key.last(),Model.MODEL);
}
else if (key.first().equals(Ranking.RANKING)) {
Ranking ranking = query.getRanking();
if (key.size()==2) {
if (key.last().equals(Ranking.LOCATION))
ranking.setLocation(asString(value,""));
else if (key.last().equals(Ranking.PROFILE))
ranking.setProfile(asString(value,""));
else if (key.last().equals(Ranking.SORTING))
ranking.setSorting(asString(value,""));
else if (key.last().equals(Ranking.FRESHNESS))
ranking.setFreshness(asString(value, ""));
else if (key.last().equals(Ranking.QUERYCACHE))
ranking.setQueryCache(asBoolean(value, false));
else if (key.last().equals(Ranking.LIST_FEATURES))
ranking.setListFeatures(asBoolean(value,false));
}
else if (key.size()>=3 && key.get(1).equals(Ranking.MATCH_PHASE)) {
if (key.size() == 3) {
MatchPhase matchPhase = ranking.getMatchPhase();
if (key.last().equals(MatchPhase.ATTRIBUTE)) {
matchPhase.setAttribute(asString(value, null));
} else if (key.last().equals(MatchPhase.ASCENDING)) {
matchPhase.setAscending(asBoolean(value, false));
} else if (key.last().equals(MatchPhase.MAX_HITS)) {
matchPhase.setMaxHits(asLong(value, null));
} else if (key.last().equals(MatchPhase.MAX_FILTER_COVERAGE)) {
matchPhase.setMaxFilterCoverage(asDouble(value, 0.2));
}
} else if (key.size() > 3 && key.get(2).equals(Ranking.DIVERSITY)) {
Diversity diversity = ranking.getMatchPhase().getDiversity();
if (key.last().equals(Diversity.ATTRIBUTE)) {
diversity.setAttribute(asString(value, null));
} else if (key.last().equals(Diversity.MINGROUPS)) {
diversity.setMinGroups(asLong(value, null));
} else if ((key.size() > 4) && key.get(3).equals(Diversity.CUTOFF)) {
if (key.last().equals(Diversity.FACTOR)) {
diversity.setCutoffFactor(asDouble(value, 10.0));
} else if (key.last().equals(Diversity.STRATEGY)) {
diversity.setCutoffStrategy(asString(value, "loose"));
}
}
}
}
else if (key.size() == 3 && key.get(1).equals(Ranking.SOFTTIMEOUT)) {
SoftTimeout soft = ranking.getSoftTimeout();
if (key.last().equals(SoftTimeout.ENABLE)) soft.setEnable(asBoolean(value, false));
if (key.last().equals(SoftTimeout.FACTOR)) soft.setFactor(asDouble(value, 0.50));
if (key.last().equals(SoftTimeout.TAILCOST)) soft.setTailcost(asDouble(value, 0.10));
}
else if (key.size() == 3 && key.get(1).equals(Ranking.MATCHING)) {
Matching matching = ranking.getMatching();
if (key.last().equals(Matching.TERMWISELIMIT)) matching.setTermwiselimit(asDouble(value, 1.0));
if (key.last().equals(Matching.NUMTHREADSPERSEARCH)) matching.setNumThreadsPerSearch(asInteger(value, 1));
if (key.last().equals(Matching.NUMSEARCHPARTITIIONS)) matching.setNumSearchPartitions(asInteger(value, 1));
if (key.last().equals(Matching.MINHITSPERTHREAD)) matching.setMinHitsPerThread(asInteger(value, 0));
}
else if (key.size()>2) {
String restKey = key.rest().rest().toString();
if (key.get(1).equals(Ranking.FEATURES))
setRankingFeature(query, restKey, toSpecifiedType(restKey, value, profileRegistry.getTypeRegistry().getComponent("features")));
else if (key.get(1).equals(Ranking.PROPERTIES))
ranking.getProperties().put(restKey, toSpecifiedType(restKey, value, profileRegistry.getTypeRegistry().getComponent("properties")));
else
throwIllegalParameter(key.rest().toString(),Ranking.RANKING);
}
}
else if (key.size()==2 && key.first().equals(Presentation.PRESENTATION)) {
if (key.last().equals(Presentation.BOLDING))
query.getPresentation().setBolding(asBoolean(value, true));
else if (key.last().equals(Presentation.SUMMARY))
query.getPresentation().setSummary(asString(value, ""));
else if (key.last().equals(Presentation.FORMAT))
query.getPresentation().setFormat(asString(value,""));
else if (key.last().equals(Presentation.TIMING))
query.getPresentation().setTiming(asBoolean(value, true));
else if (key.last().equals(Presentation.SUMMARY_FIELDS))
query.getPresentation().setSummaryFields(asString(value,""));
else if ( ! key.last().equals(Presentation.REPORT_COVERAGE))
throwIllegalParameter(key.last(), Presentation.PRESENTATION);
}
else if (key.size()==2 && key.first().equals(Select.SELECT)) {
if (key.last().equals(Select.WHERE)){
query.getSelect().setWhereString(asString(value, ""));
} else if (key.last().equals(Select.GROUPING)) {
query.getSelect().setGroupingString(asString(value, ""));
}
}
else if (key.first().equals("rankfeature") || key.first().equals("featureoverride") ) {
setRankingFeature(query, key.rest().toString(), toSpecifiedType(key.rest().toString(), value, profileRegistry.getTypeRegistry().getComponent("features")));
} else if (key.first().equals("rankproperty")) {
query.getRanking().getProperties().put(key.rest().toString(), toSpecifiedType(key.rest().toString(), value, profileRegistry.getTypeRegistry().getComponent("properties")));
} else if (key.size()==1) {
if (key.equals(Query.HITS))
query.setHits(asInteger(value,10));
else if (key.equals(Query.OFFSET))
query.setOffset(asInteger(value,0));
else if (key.equals(Query.TRACE_LEVEL))
query.setTraceLevel(asInteger(value,0));
else if (key.equals(Query.TIMEOUT))
query.setTimeout(value.toString());
else if (key.equals(Query.NO_CACHE))
query.setNoCache(asBoolean(value,false));
else if (key.equals(Query.GROUPING_SESSION_CACHE))
query.setGroupingSessionCache(asBoolean(value, false));
else
super.set(key,value,context);
} else if (key.toString().equals(GroupingRequest.PROP_REQUEST)) {
query.getSelect().setGrouping((List<GroupingRequest>) value);
}
else
super.set(key,value,context);
}
catch (Exception e) {
if (e.getMessage().startsWith("Could not set"))
throw e;
else
throw new IllegalArgumentException("Could not set '" + key + "' to '" + value + "'", e);
}
}

Line under review: } else if (key.toString().equals(GroupingRequest.PROP_REQUEST)) {

Code after addressing the review:
public void set(CompoundName key, Object value, Map<String,String> context) {
try {
if (key.size()==2 && key.first().equals(Model.MODEL)) {
Model model = query.getModel();
if (key.last().equals(Model.QUERY_STRING))
model.setQueryString(asString(value, ""));
else if (key.last().equals(Model.TYPE))
model.setType(asString(value, "ANY"));
else if (key.last().equals(Model.FILTER))
model.setFilter(asString(value, ""));
else if (key.last().equals(Model.DEFAULT_INDEX))
model.setDefaultIndex(asString(value, ""));
else if (key.last().equals(Model.LANGUAGE))
model.setLanguage(asString(value, ""));
else if (key.last().equals(Model.ENCODING))
model.setEncoding(asString(value,""));
else if (key.last().equals(Model.SEARCH_PATH))
model.setSearchPath(asString(value,""));
else if (key.last().equals(Model.SOURCES))
model.setSources(asString(value,""));
else if (key.last().equals(Model.RESTRICT))
model.setRestrict(asString(value,""));
else
throwIllegalParameter(key.last(),Model.MODEL);
}
else if (key.first().equals(Ranking.RANKING)) {
Ranking ranking = query.getRanking();
if (key.size()==2) {
if (key.last().equals(Ranking.LOCATION))
ranking.setLocation(asString(value,""));
else if (key.last().equals(Ranking.PROFILE))
ranking.setProfile(asString(value,""));
else if (key.last().equals(Ranking.SORTING))
ranking.setSorting(asString(value,""));
else if (key.last().equals(Ranking.FRESHNESS))
ranking.setFreshness(asString(value, ""));
else if (key.last().equals(Ranking.QUERYCACHE))
ranking.setQueryCache(asBoolean(value, false));
else if (key.last().equals(Ranking.LIST_FEATURES))
ranking.setListFeatures(asBoolean(value,false));
}
else if (key.size()>=3 && key.get(1).equals(Ranking.MATCH_PHASE)) {
if (key.size() == 3) {
MatchPhase matchPhase = ranking.getMatchPhase();
if (key.last().equals(MatchPhase.ATTRIBUTE)) {
matchPhase.setAttribute(asString(value, null));
} else if (key.last().equals(MatchPhase.ASCENDING)) {
matchPhase.setAscending(asBoolean(value, false));
} else if (key.last().equals(MatchPhase.MAX_HITS)) {
matchPhase.setMaxHits(asLong(value, null));
} else if (key.last().equals(MatchPhase.MAX_FILTER_COVERAGE)) {
matchPhase.setMaxFilterCoverage(asDouble(value, 0.2));
}
} else if (key.size() > 3 && key.get(2).equals(Ranking.DIVERSITY)) {
Diversity diversity = ranking.getMatchPhase().getDiversity();
if (key.last().equals(Diversity.ATTRIBUTE)) {
diversity.setAttribute(asString(value, null));
} else if (key.last().equals(Diversity.MINGROUPS)) {
diversity.setMinGroups(asLong(value, null));
} else if ((key.size() > 4) && key.get(3).equals(Diversity.CUTOFF)) {
if (key.last().equals(Diversity.FACTOR)) {
diversity.setCutoffFactor(asDouble(value, 10.0));
} else if (key.last().equals(Diversity.STRATEGY)) {
diversity.setCutoffStrategy(asString(value, "loose"));
}
}
}
}
else if (key.size() == 3 && key.get(1).equals(Ranking.SOFTTIMEOUT)) {
SoftTimeout soft = ranking.getSoftTimeout();
if (key.last().equals(SoftTimeout.ENABLE)) soft.setEnable(asBoolean(value, false));
if (key.last().equals(SoftTimeout.FACTOR)) soft.setFactor(asDouble(value, 0.50));
if (key.last().equals(SoftTimeout.TAILCOST)) soft.setTailcost(asDouble(value, 0.10));
}
else if (key.size() == 3 && key.get(1).equals(Ranking.MATCHING)) {
Matching matching = ranking.getMatching();
if (key.last().equals(Matching.TERMWISELIMIT)) matching.setTermwiselimit(asDouble(value, 1.0));
if (key.last().equals(Matching.NUMTHREADSPERSEARCH)) matching.setNumThreadsPerSearch(asInteger(value, 1));
if (key.last().equals(Matching.NUMSEARCHPARTITIIONS)) matching.setNumSearchPartitions(asInteger(value, 1));
if (key.last().equals(Matching.MINHITSPERTHREAD)) matching.setMinHitsPerThread(asInteger(value, 0));
}
else if (key.size()>2) {
String restKey = key.rest().rest().toString();
if (key.get(1).equals(Ranking.FEATURES))
setRankingFeature(query, restKey, toSpecifiedType(restKey, value, profileRegistry.getTypeRegistry().getComponent("features")));
else if (key.get(1).equals(Ranking.PROPERTIES))
ranking.getProperties().put(restKey, toSpecifiedType(restKey, value, profileRegistry.getTypeRegistry().getComponent("properties")));
else
throwIllegalParameter(key.rest().toString(),Ranking.RANKING);
}
}
else if (key.size()==2 && key.first().equals(Presentation.PRESENTATION)) {
if (key.last().equals(Presentation.BOLDING))
query.getPresentation().setBolding(asBoolean(value, true));
else if (key.last().equals(Presentation.SUMMARY))
query.getPresentation().setSummary(asString(value, ""));
else if (key.last().equals(Presentation.FORMAT))
query.getPresentation().setFormat(asString(value,""));
else if (key.last().equals(Presentation.TIMING))
query.getPresentation().setTiming(asBoolean(value, true));
else if (key.last().equals(Presentation.SUMMARY_FIELDS))
query.getPresentation().setSummaryFields(asString(value,""));
else if ( ! key.last().equals(Presentation.REPORT_COVERAGE))
throwIllegalParameter(key.last(), Presentation.PRESENTATION);
}
else if (key.size()==2 && key.first().equals(Select.SELECT)) {
if (key.last().equals(Select.WHERE)){
query.getSelect().setWhereString(asString(value, ""));
} else if (key.last().equals(Select.GROUPING)) {
query.getSelect().setGroupingString(asString(value, ""));
}
}
else if (key.first().equals("rankfeature") || key.first().equals("featureoverride") ) {
setRankingFeature(query, key.rest().toString(), toSpecifiedType(key.rest().toString(), value, profileRegistry.getTypeRegistry().getComponent("features")));
} else if (key.first().equals("rankproperty")) {
query.getRanking().getProperties().put(key.rest().toString(), toSpecifiedType(key.rest().toString(), value, profileRegistry.getTypeRegistry().getComponent("properties")));
} else if (key.size()==1) {
if (key.equals(Query.HITS))
query.setHits(asInteger(value,10));
else if (key.equals(Query.OFFSET))
query.setOffset(asInteger(value,0));
else if (key.equals(Query.TRACE_LEVEL))
query.setTraceLevel(asInteger(value,0));
else if (key.equals(Query.TIMEOUT))
query.setTimeout(value.toString());
else if (key.equals(Query.NO_CACHE))
query.setNoCache(asBoolean(value,false));
else if (key.equals(Query.GROUPING_SESSION_CACHE))
query.setGroupingSessionCache(asBoolean(value, false));
else
super.set(key,value,context);
} else
super.set(key,value,context);
}
catch (Exception e) {
if (e.getMessage().startsWith("Could not set"))
throw e;
else
throw new IllegalArgumentException("Could not set '" + key + "' to '" + value + "'", e);
}
}